Log implementation.
More...
#include "compile_time.h"
#include "src/lib/log.h"
#include "dist/sds/sds.h"
#include "src/lib/config/env.h"
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
|
| _Thread_local sds | thread_logname |
| | Thread name.
|
|
_Thread_local sds | thread_logline |
| | Thread specific log buffer.
|
| _Atomic int | loglevel |
| | Loglevel.
|
|
enum log_types | log_type |
| | Type of logging system.
|
| static const char * | loglevel_names [8] |
| static const char * | loglevel_colors [8] |
◆ get_loglevel_name()
| const char * get_loglevel_name |
( |
int | level | ) |
|
Returns the name of the loglevel
- Parameters
-
- Returns
- the loglevel name or empty string if loglevel is invalid
◆ log_init()
Initializes the logging sub-system
◆ mympd_log()
| void mympd_log |
( |
int | level, |
|
|
const char * | file, |
|
|
int | line, |
|
|
const char * | partition, |
|
|
const char * | fmt, |
|
|
| ... ) |
Logging function This function should be called by the suitable macro
- Parameters
-
| level | loglevel of the message |
| file | filename for debug logging |
| line | linenumber for debug logging |
| partition | mpd partition |
| fmt | format string to print |
| ... | arguments for the format string |
◆ mympd_log_errno()
| void mympd_log_errno |
( |
const char * | file, |
|
|
int | line, |
|
|
const char * | partition, |
|
|
int | errnum ) |
Logs the errno string This function should be called by the suitable macro
- Parameters
-
| file | filename for debug logging |
| line | linenumber for debug logging |
| partition | mpd partition |
| errnum | errno |
◆ set_loglevel()
| void set_loglevel |
( |
int | level | ) |
|
Sets the loglevel
- Parameters
-
◆ loglevel
Loglevel.
Global variables
◆ loglevel_colors
| const char* loglevel_colors[8] |
|
static |
Initial value:= {
[LOG_EMERG] = "\033[0;31m",
[LOG_ALERT] = "\033[0;31m",
[LOG_CRIT] = "\033[0;31m",
[LOG_ERR] = "\033[0;31m",
[LOG_WARNING] = "\033[0;33m",
[LOG_NOTICE] = "",
[LOG_INFO] = "",
[LOG_DEBUG] = "\033[0;32m"
}
Maps loglevels to terminal colors
◆ loglevel_names
| const char* loglevel_names[8] |
|
static |
Initial value:= {
[LOG_EMERG] = "EMERG",
[LOG_ALERT] = "ALERT",
[LOG_CRIT] = "CRITICAL",
[LOG_ERR] = "ERROR",
[LOG_WARNING] = "WARN",
[LOG_NOTICE] = "NOTICE",
[LOG_INFO] = "INFO",
[LOG_DEBUG] = "DEBUG"
}
Maps loglevels to names
◆ thread_logname
| _Thread_local sds thread_logname |
Thread name.
Thread specific variables