|
enum | LogLevel {
LL_DEBUG
, LL_VERBOSE
, LL_INFO
, LL_WARN
,
LL_ERROR
, LL_FATAL
} |
| The various log levels used in STK.
|
|
|
| LOG (verbose, LL_VERBOSE) |
|
| LOG (debug, LL_DEBUG) |
|
| LOG (info, LL_INFO) |
|
| LOG (warn, LL_WARN) |
|
| LOG (error, LL_ERROR) |
|
| LOG (fatal, LL_FATAL) |
|
|
static void | openOutputFiles (const std::string &logout) |
| This function opens the files that will contain the output.
|
|
static void | closeOutputFiles () |
| Function to close output files.
|
|
static void | flushBuffers () |
| Flushes all stored log messages to the various output devices (thread safe).
|
|
static void | toggleConsoleLog (bool val) |
|
static void | setBufferSize (size_t n) |
| Sets the number of lines to buffer.
|
|
static void | setLogLevel (int n) |
| Defines the minimum log level to be displayed.
|
|
static LogLevel | getLogLevel () |
| Returns the log level.
|
|
static void | disableColor () |
| Disable coloring of log messages.
|
|
static void | setPrefix (const char *prefix) |
| Sets a prefix to be printed before each line.
|
|
|
static void | setTerminalColor (LogLevel level) |
| Selects background/foreground colors for the message depending on log level.
|
|
static void | resetTerminalColor () |
| Resets the terminal color to the default, and adds a new line (if a new line is added as part of the message, a potential change of background color will also affect the next row).
|
|
static void | writeLine (const char *line, int level) |
| Writes the specified line to the various output devices, e.g.
|
|
static void | printMessage (int level, const char *component, const char *format, VALIST va_list) |
| This actually creates a log message.
|
|
|
static LogLevel | m_min_log_level = Log::LL_VERBOSE |
| Which message level to print.
|
|
static bool | m_no_colors = false |
| If set this will disable coloring of log messages.
|
|
static bool | m_console_log = true |
| If false that logging will only be saved to a file.
|
|
static FILE * | m_file_stdout = NULL |
| The file where stdout output will be written.
|
|
static Synchronised< std::vector< struct LineInfo > > | m_line_buffer |
|
static size_t | m_buffer_size = 1 |
| <0 if no buffered logging is to be used, otherwise this is the maximum number of lines the buffer should hold.
|
|
◆ getLogLevel()
Returns the log level.
This is useful if some work is necessary to preprate output strings, which might not be used at all (example: replacing the cleartext password in an http request).
◆ openOutputFiles()
void Log::openOutputFiles |
( |
const std::string & |
logout | ) |
|
|
static |
This function opens the files that will contain the output.
- Parameters
-
logout | : name of the file that will contain stdout output |
logerr | : name of the file that will contain stderr output |
◆ printMessage()
void Log::printMessage |
( |
int |
level, |
|
|
const char * |
component, |
|
|
const char * |
format, |
|
|
VALIST |
args |
|
) |
| |
|
staticprivate |
This actually creates a log message.
If the messages are to be buffered, it will be appended to the output buffer. If the buffer is full, it will be flushed. If the message is not to be buffered, it will be immediately written using writeLine().
- Parameters
-
level | Log level of the message to print. |
format | A printf-like format string. |
va_list | The values to be printed for the format. |
◆ setBufferSize()
static void Log::setBufferSize |
( |
size_t |
n | ) |
|
|
inlinestatic |
Sets the number of lines to buffer.
Setting the buffer size to a a value <=1 means no buffering, lines will be immediately printed.
◆ setPrefix()
void Log::setPrefix |
( |
const char * |
prefix | ) |
|
|
static |
Sets a prefix to be printed before each line.
To disable the prefix, set it to "", max length of prefix is 10, if larger than that the remaining characters are ignored.
◆ setTerminalColor()
void Log::setTerminalColor |
( |
LogLevel |
level | ) |
|
|
staticprivate |
Selects background/foreground colors for the message depending on log level.
It is only called if messages are not redirected to a file.
- Parameters
-
level | The level for which to set the color. |
◆ writeLine()
void Log::writeLine |
( |
const char * |
line, |
|
|
int |
level |
|
) |
| |
|
staticprivate |
Writes the specified line to the various output devices, e.g.
terminal, log file etc. If log messages are not redirected to a file, it tries to select a terminal colour.
- Parameters
-
line | The line to write. |
level | Message level. Only used to select terminal colour. |
The documentation for this class was generated from the following files: