about summary refs log tree commit diff
path: root/src/libnm-glib-aux/nm-logging-base.h
blob: 3d76b37861ee17c53413f442e18f323e18340b37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* SPDX-License-Identifier: LGPL-2.1-or-later */

#ifndef __NM_LOGGING_BASE_H__
#define __NM_LOGGING_BASE_H__

#include "nm-logging-fwd.h"

typedef struct {
    const char *name;
    const char *level_str;

    /* nm-logging uses syslog internally. Note that the three most-verbose syslog levels
     * are LOG_DEBUG, LOG_INFO and LOG_NOTICE. Journal already highlights LOG_NOTICE
     * as special.
     *
     * On the other hand, we have three levels LOGL_TRACE, LOGL_DEBUG and LOGL_INFO,
     * which are regular messages not to be highlighted. For that reason, we must map
     * LOGL_TRACE and LOGL_DEBUG both to syslog level LOG_DEBUG. */
    int syslog_level;

    GLogLevelFlags g_log_level;
} LogLevelDesc;

extern const LogLevelDesc nm_log_level_desc[_LOGL_N];

gboolean _nm_log_parse_level(const char *level, NMLogLevel *out_level);

/*****************************************************************************/

extern volatile NMLogLevel _nm_logging_enabled_value;

static inline gboolean
_nm_logging_enabled(NMLogLevel level)
{
    return level >= _nm_logging_enabled_value;
}

void _nm_logging_enabled_init(const char *level_str);

/*****************************************************************************/

void _nm_log_simple_printf(NMLogLevel level, const char *fmt, ...) _nm_printf(2, 3);

#endif /* __NM_LOGGING_BASE_H__ */