A multi-threaded logger for logging to one or more destinations.
More...
#include <Logger.h>
A multi-threaded logger for logging to one or more destinations.
A default logger is provided via madara::logger::global_logger in GlobalLogger.h
Definition at line 88 of file Logger.h.
guard for access and changes
vector of file handles
Definition at line 169 of file Logger.h.
madara::logger::Logger::Logger |
( |
bool |
log_to_stderr = true | ) |
|
Constructor.
- Parameters
-
log_to_stderr | if true, log to stderr by default |
Definition at line 6 of file Logger.cpp.
madara::logger::Logger::~Logger |
( |
| ) |
|
void madara::logger::Logger::add_file |
( |
const std::string & |
filename | ) |
|
|
inline |
Adds a file to the logger.
- Parameters
-
filename | the file to open and add to writing |
Definition at line 14 of file Logger.inl.
void madara::logger::Logger::add_syslog |
( |
void |
| ) |
|
|
inline |
Adds the system log.
Definition at line 84 of file Logger.inl.
void madara::logger::Logger::add_term |
( |
void |
| ) |
|
|
inline |
Adds terminal to logger outputs.
Definition at line 76 of file Logger.inl.
void madara::logger::Logger::clear |
( |
void |
| ) |
|
|
inline |
Clears all log targets.
Definition at line 92 of file Logger.inl.
int madara::logger::Logger::get_level |
( |
void |
| ) |
|
|
inline |
Gets the maximum logging detail level.
- Returns
- the maximum level of log detail
Definition at line 68 of file Logger.inl.
std::string madara::logger::Logger::get_tag |
( |
void |
| ) |
|
|
inline |
Gets the tag used for syslogs.
- Returns
- the tag used for any system logging
Definition at line 52 of file Logger.inl.
void madara::logger::Logger::log |
( |
int |
level, |
|
|
const char * |
message, |
|
|
|
... |
|
) |
| |
Logs a message to all available loggers.
- Parameters
-
- See also
- LogLevels
- Parameters
-
message | the message to log |
Definition at line 23 of file Logger.cpp.
void madara::logger::Logger::set_level |
( |
int |
level | ) |
|
|
inline |
Sets the maximum logging detail level.
- Parameters
-
level | the maximum level of log detail |
Definition at line 44 of file Logger.inl.
void madara::logger::Logger::set_tag |
( |
const std::string & |
tag | ) |
|
|
inline |
Sets the tag used for syslogs (e.g.
Android Log)
- Parameters
-
tag | the tag to use for any system logging |
Definition at line 60 of file Logger.inl.
void madara::logger::Logger::set_timestamp_format |
( |
const std::string & |
format = "%x %X: " | ) |
|
|
inline |
Sets timestamp format.
Uses strftime for formatting time.
- Parameters
-
format | the format of the timestamp. See C++ strftime definition for common usage. |
Definition at line 112 of file Logger.inl.
list of all log outputs
Definition at line 175 of file Logger.h.
int madara::logger::Logger::level_ |
|
private |
the maximum detail level for logging
Definition at line 178 of file Logger.h.
MADARA_LOCK_TYPE madara::logger::Logger::mutex_ |
|
mutableprivate |
mutex for changes
Definition at line 172 of file Logger.h.
bool madara::logger::Logger::syslog_added_ |
|
private |
tracks whether the system log has been added
Definition at line 184 of file Logger.h.
std::string madara::logger::Logger::tag_ |
|
private |
the tag used for logging to system logs
Definition at line 187 of file Logger.h.
bool madara::logger::Logger::term_added_ |
|
private |
tracks whether terminal output has been added
Definition at line 181 of file Logger.h.
std::string madara::logger::Logger::timestamp_format_ |
|
private |
the timestamp format. Default is "" for no timestamp
Definition at line 190 of file Logger.h.
The documentation for this class was generated from the following files: