23 #define snprintf _snprintf 43 RTL_SILENT, RTL_PARANOID, RTL_SILENT),
44 m_name(name), m_dateFormat(
"%b %d %H:%M:%S.%Q"),
45 m_msEnable(0), m_usEnable(0)
113 const char* color[] =
125 *
this << color[
level];
139 const int maxsize = 256;
147 date = gmtime(&timer);
150 std::string fmt(buf);
156 _snprintf(msec, 4,
"%03d", (
int)(tm.
usec() / 1000));
158 snprintf(msec, 4,
"%03d", (
int)(tm.
usec() / 1000));
166 _snprintf(usec, 4,
"%03d",
167 (
int)(tm.
usec() - ((tm.
usec() / 1000) * 1000)));
169 snprintf(usec, 4,
"%03d",
170 (
int)(tm.
usec() - ((tm.
usec() / 1000) * 1000)));
187 std::string lv(level);
190 else if (lv ==
"FATAL")
192 else if (lv ==
"ERROR")
194 else if (lv ==
"WARN")
196 else if (lv ==
"INFO")
198 else if (lv ==
"DEBUG")
200 else if (lv ==
"TRACE")
202 else if (lv ==
"VERBOSE")
204 else if (lv ==
"PARANOID")
void setDateFormat(const char *format)
Set date/time format for adding the header.
virtual ~Logger(void)
Virtual destructor.
virtual void header(int level)
Message prefix appender function.
log_streambuf template class
RT component logger class.
void setName(const char *name)
Set suffix of date/time string of header.
static Manager & instance()
Get instance of the manager.
RTComponent manager class.
int gettimeofday(struct timeval *tv, struct timezone *tz)
Get the time and timezone.
log_stream template class
bool setLevel(int level)
Set the log level.
unsigned int replaceString(std::string &str, const std::string from, const std::string to)
Replace string.
bool setLevel(const char *level)
Set log level by string.
ostream_type & level(int level)
Acquire log stream.
long int sec() const
Get value of second time scale.
long int usec() const
Get value of micro second time scale.
Logger(const char *name="")
Constructor.
int strToLevel(const char *level)
Set the log level Set the log level corresponding to the given string.
static const char * m_levelString[]
std::string getDate(void)
Get the current formatted date/time string Get the current datetime described by specified format...
Common Object Interface Layer.