Debian Codegraph @

src/utils/logging.h

raw
1 #include <glib.h>
2 #include <syslog.h>
3
4 #ifndef BD_UTILS_LOGGING
5 #define BD_UTILS_LOGGING
6
7 /* These are same as syslog levels, unfortunately GObject Introspection
8 * doesn't work with "redefined" constants so we can't use syslog
9 * constants here.
10 */
11 #define BD_UTILS_LOG_EMERG 0
12 #define BD_UTILS_LOG_ALERT 1
13 #define BD_UTILS_LOG_CRIT 2
14 #define BD_UTILS_LOG_ERR 3
15 #define BD_UTILS_LOG_WARNING 4
16 #define BD_UTILS_LOG_NOTICE 5
17 #define BD_UTILS_LOG_INFO 6
18 #define BD_UTILS_LOG_DEBUG 7
19
20 /**
21 * BDUtilsLogFunc:
22 * @level: log level (as understood by syslog(3))
23 * @msg: log message
24 *
25 * Function type for logging function used by the libblockdev's exec utils to
26 * log the information about program executing.
27 */
28 typedef void (*BDUtilsLogFunc) (gint level, const gchar *msg);
29
30 gboolean bd_utils_init_logging (BDUtilsLogFunc new_log_func, GError **error);
31
32 void bd_utils_set_log_level (gint level);
33
34 void bd_utils_log (gint level, const gchar *msg);
35 void bd_utils_log_format (gint level, const gchar *format, ...) G_GNUC_PRINTF (2, 3);
36 void bd_utils_log_stdout (gint level, const gchar *msg);
37
38 #endif /* BD_UTILS_LOGGING */