myMPD
Internal API documentation
Loading...
Searching...
No Matches
log.c File Reference

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>
Include dependency graph for log.c:

Functions

const char * get_loglevel_name (int level)
void set_loglevel (int level)
void log_init (void)
void mympd_log_errno (const char *file, int line, const char *partition, int errnum)
void mympd_log (int level, const char *file, int line, const char *partition, const char *fmt,...)

Variables

_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]

Detailed Description

Log implementation.

Function Documentation

◆ get_loglevel_name()

const char * get_loglevel_name ( int level)

Returns the name of the loglevel

Parameters
level
Returns
the loglevel name or empty string if loglevel is invalid

◆ log_init()

void log_init ( void )

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
levelloglevel of the message
filefilename for debug logging
linelinenumber for debug logging
partitionmpd partition
fmtformat 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
filefilename for debug logging
linelinenumber for debug logging
partitionmpd partition
errnumerrno

◆ set_loglevel()

void set_loglevel ( int level)

Sets the loglevel

Parameters
levelloglevel to set

Variable Documentation

◆ loglevel

_Atomic int 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