8 term_added_ (log_to_terminal), syslog_added_ (false), tag_ (
"madara"),
28 va_start (argptr, message);
32 char * begin = (
char *)buffer;
33 size_t remaining_buffer =
sizeof (buffer);
41 timeinfo = localtime (&rawtime);
43 size_t chars_written = strftime (
46 remaining_buffer -= chars_written;
47 begin += chars_written;
50 vsnprintf (begin, remaining_buffer, message, argptr);
54 MADARA_GUARD_TYPE guard (
mutex_);
56 #ifdef _MADARA_ANDROID_ 61 __android_log_write (ANDROID_LOG_ERROR,
tag_.c_str (), buffer);
65 __android_log_write (ANDROID_LOG_WARN,
tag_.c_str (), buffer);
69 __android_log_write (ANDROID_LOG_INFO,
tag_.c_str (), buffer);
72 #else // end if _USING_ANDROID_ 75 fprintf (stderr,
"%s", buffer);
80 for (FileVectors::iterator i =
files_.begin ();
85 fprintf (stderr,
"Logger::log: writing to file num %d", file_num);
90 fprintf (*i,
"%s", buffer);
int level_
the maximum detail level for logging
std::string timestamp_format_
the timestamp format. Default is "" for no timestamp
bool term_added_
tracks whether terminal output has been added
Logger(bool log_to_stderr=true)
Constructor.
FileVectors files_
list of all log outputs
bool syslog_added_
tracks whether the system log has been added
void add_term(void)
Adds terminal to logger outputs.
void log(int level, const char *message,...)
Logs a message to all available loggers.
void clear(void)
Clears all log targets.
MADARA_LOCK_TYPE mutex_
mutex for changes
std::string tag_
the tag used for logging to system logs