Dunst
Lightweight notification daemon
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause */
10
11#include <errno.h>
12#include <glib.h>
13#include <stdbool.h>
14#include <stdio.h>
15#include <stdlib.h>
16
17#ifndef DUNST_LOG_H
18#define DUNST_LOG_H
19
32#if __GNUC__ >= 8 || __clang_major__ >= 6
33#define MSG(format, ...) "[%16s:%04d] " format, __func__, __LINE__, ## __VA_ARGS__
34#endif
35
36#ifdef MSG
37// These should benefit from more context
38#define LOG_E(...) g_error(MSG(__VA_ARGS__))
39#define LOG_C(...) g_critical(MSG(__VA_ARGS__))
40#define LOG_D(...) g_debug(MSG(__VA_ARGS__))
41#else
42#define LOG_E g_error
43#define LOG_C g_critical
44#define LOG_D g_debug
45#endif
46
47#define LOG_W g_warning
48#define LOG_M g_message
49#define LOG_I g_info
50
51#define DIE(...) do { LOG_C(__VA_ARGS__); exit(EXIT_FAILURE); } while (0)
52
53// Unified fopen() result messages
54#define MSG_FOPEN_SUCCESS(path, fp) "Opened '%s' (fd: '%d')", path, fileno(fp)
55#define MSG_FOPEN_FAILURE(path) "Cannot open '%s': %s", path, strerror(errno)
56
57enum log_mask {
58 DUNST_LOG_NONE,
59 DUNST_LOG_ALL,
60 DUNST_LOG_AUTO,
61};
62
71void log_set_level(GLogLevelFlags level);
72
81void log_set_level_from_string(const char* level);
82
89void dunst_log_init(enum log_mask mask);
90
91#endif
void log_set_level_from_string(const char *level)
Set the current loglevel to level
Definition log.c:32
void dunst_log_init(enum log_mask mask)
Initialise log handling.
Definition log.c:95
void log_set_level(GLogLevelFlags level)
Set the current loglevel to level
Definition log.c:58