Dunst
Lightweight notification daemon
Loading...
Searching...
No Matches
log.h File Reference

Logging subsystem and helpers. More...

#include <errno.h>
#include <glib.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
+ Include dependency graph for log.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LOG_E   g_error
 Prefix message with "[<source path>:<function name>:<line number>] ".
 
#define LOG_C   g_critical
 
#define LOG_D   g_debug
 
#define LOG_W   g_warning
 
#define LOG_M   g_message
 
#define LOG_I   g_info
 
#define DIE(...)
 
#define MSG_FOPEN_SUCCESS(path, fp)
 
#define MSG_FOPEN_FAILURE(path)
 

Enumerations

enum  log_mask { DUNST_LOG_NONE , DUNST_LOG_ALL , DUNST_LOG_AUTO }
 

Functions

void log_set_level (GLogLevelFlags level)
 Set the current loglevel to level
 
void log_set_level_from_string (const char *level)
 Set the current loglevel to level
 
void dunst_log_init (enum log_mask mask)
 Initialise log handling.
 

Detailed Description

Logging subsystem and helpers.

License
BSD-3-Clause

Definition in file log.h.

Macro Definition Documentation

◆ DIE

#define DIE ( ...)
Value:
do { LOG_C(__VA_ARGS__); exit(EXIT_FAILURE); } while (0)

Definition at line 51 of file log.h.

◆ LOG_C

#define LOG_C   g_critical

Definition at line 43 of file log.h.

◆ LOG_D

#define LOG_D   g_debug

Definition at line 44 of file log.h.

◆ LOG_E

#define LOG_E   g_error

Prefix message with "[<source path>:<function name>:<line number>] ".

Parameters
formatis either a format string like the first argument of printf() or a string literal. ... are the arguments to above format string.

This requires -Wno-gnu-zero-variadic-macro-arguments with clang because of token pasting ',' and __VA_ARGS__ being a GNU extension. However, the result is the same with both gcc and clang and since we are compiling with '-std=gnu99', this should be fine.

Definition at line 42 of file log.h.

◆ LOG_I

#define LOG_I   g_info

Definition at line 49 of file log.h.

◆ LOG_M

#define LOG_M   g_message

Definition at line 48 of file log.h.

◆ LOG_W

#define LOG_W   g_warning

Definition at line 47 of file log.h.

◆ MSG_FOPEN_FAILURE

#define MSG_FOPEN_FAILURE ( path)
Value:
"Cannot open '%s': %s", path, strerror(errno)

Definition at line 55 of file log.h.

◆ MSG_FOPEN_SUCCESS

#define MSG_FOPEN_SUCCESS ( path,
fp )
Value:
"Opened '%s' (fd: '%d')", path, fileno(fp)

Definition at line 54 of file log.h.

Enumeration Type Documentation

◆ log_mask

enum log_mask

Definition at line 57 of file log.h.

Function Documentation

◆ dunst_log_init()

void dunst_log_init ( enum log_mask mask)

Initialise log handling.

Can be called any time.

Parameters
maskIf we're in testing mode and should suppress all output or show all

Definition at line 95 of file log.c.

◆ log_set_level()

void log_set_level ( GLogLevelFlags level)

Set the current loglevel to level

Parameters
levelThe desired log level

If level is NULL, nothing will be done. If level is an invalid value, nothing will be done.

Definition at line 58 of file log.c.

◆ log_set_level_from_string()

void log_set_level_from_string ( const char * level)

Set the current loglevel to level

Parameters
levelThe desired log level as a string

If level is NULL, nothing will be done. If level is an invalid value, nothing will be done.

Definition at line 32 of file log.c.