Turi Create
4.0
|
#include <core/logging/logger.hpp>
Public Member Functions | |
file_logger () | |
bool | set_log_file (std::string file) |
destructor. flushes and closes the current logger file More... | |
void | set_log_to_console (bool consolelog, bool _log_to_stderr=false) |
void | set_pid (size_t pid) |
size_t | get_pid () const |
std::string | get_log_file (void) |
Returns the current logger file. | |
bool | get_log_to_console () |
Returns true if output is being written to stderr. | |
int | get_log_level () |
Returns the current logger level. | |
void | add_observer (int loglevel, std::function< void(int lineloglevel, const char *buf, size_t len)> callback_fn) |
std::function< void(int lineloglevel, const char *buf, size_t len)> | get_observer (int loglevel) |
template<typename T > | |
file_logger & | operator<< (T a) |
file_logger & | operator<< (const char *a) |
file_logger & | operator<< (std::ostream &(*f)(std::ostream &)) |
void | set_log_level (int new_log_level) |
void | _log (int loglevel, const char *file, const char *function, size_t line, const char *fmt, va_list arg) |
The main logging class.
This writes to a file, and/or the system console. The main logger global_logger is a global instance of this class.
Definition at line 474 of file logger.hpp.
file_logger::file_logger | ( | ) |
Default constructor. By default, log_to_console is on, there is no logger file, and logger level is set to LOG_EMPH
void file_logger::_log | ( | int | loglevel, |
const char * | file, | ||
const char * | function, | ||
size_t | line, | ||
const char * | fmt, | ||
va_list | arg | ||
) |
logs the message if loglevel>=OUTPUTLEVEL This function should not be used directly. Use logger()
loglevel | Type of message |
file | File where the logger call originated |
function | Function where the logger call originated |
line | Line number where the logger call originated |
fmt | printf format string |
arg | var args. The parameters that match the format string |
|
inline |
Set a callback to be called whenever a log message at a particular log level is issued. Only one observer can be set per log level.
Definition at line 532 of file logger.hpp.
|
inline |
Gets the callback called when a log message at a particular log level is issued. Note that only one observer can be set per log level.
Definition at line 545 of file logger.hpp.
|
inline |
If consolelog is true, subsequent logger output will be written to stdout / stderr. If log_to_stderr is true, all output is logged to stderr.
Definition at line 509 of file logger.hpp.
|
inline |
Streams a value into the logger.
Definition at line 555 of file logger.hpp.
|
inline |
Streams a value into the logger.
Definition at line 573 of file logger.hpp.
|
inline |
Streams an std::endl into the logger.
Definition at line 595 of file logger.hpp.
bool file_logger::set_log_file | ( | std::string | file | ) |
destructor. flushes and closes the current logger file
Closes the current logger file if one exists. if 'file' is not an empty string, it will be opened and all subsequent logger output will be written into 'file'. Any existing content of 'file' will be cleared. Return true on success and false on failure.
|
inline |
Sets the current logger level. All logging commands below the current logger level will not be written.
Definition at line 625 of file logger.hpp.
|
inline |
If consolelog is true, subsequent logger output will be written to stdout / stderr. If log_to_stderr is true, all output is logged to stderr.
Definition at line 494 of file logger.hpp.
|
inline |
If consolelog is true, subsequent logger output will be written to stdout / stderr. If log_to_stderr is true, all output is logged to stderr.
Definition at line 502 of file logger.hpp.