6
typedef void (*DSExceptionHandler)(int err, const gchar *msg);
9
#define ds_log(log_levels, module, err, ...) \
10
_ds_log_message(0, G_LOG_DOMAIN, log_levels, (log_levels&DS_LOG_FATAL_MESSAGE)?__FILE__:NULL, __func__, __LINE__, NULL, module, NULL, NULL, err, __VA_ARGS__)
12
#define ds_conditional_log(condition, log_levels, module, err, ...) \
13
_ds_log_message(condition, G_LOG_DOMAIN, log_levels, (log_levels&DS_LOG_FATAL_MESSAGE)?__FILE__:NULL, __func__, __LINE__, NULL, module, NULL, NULL, err, __VA_ARGS__)
15
#define ds_custom_log(condition, log_levels, module, prefix, err, ...) \
16
_ds_log_message(condition, G_LOG_DOMAIN, log_levels, (log_levels&DS_LOG_FATAL_MESSAGE)?__FILE__:NULL, __func__, __LINE__, NULL, module, NULL, prefix, err, __VA_ARGS__)
19
#define ds_debug(...) ds_log(G_LOG_LEVEL_DEBUG, NULL, 0, __VA_ARGS__)
20
#define ds_info(...) ds_log(G_LOG_LEVEL_INFO, NULL, 0, __VA_ARGS__)
21
#define ds_warning(...) ds_log(G_LOG_LEVEL_WARNING, NULL, 0, __VA_ARGS__)
22
#define ds_error(...) ds_log(G_LOG_LEVEL_CRITICAL, NULL, 0, __VA_ARGS__)
23
#define ds_fail(...) ds_log((GLogLevelFlags)(G_LOG_LEVEL_ERROR|DS_LOG_FATAL_MESSAGE), NULL, 0, __VA_ARGS__)
26
#define ds_exception(cond, err, ...) ds_conditional_log(cond, G_LOG_LEVEL_CRITICAL, NULL, err, __VA_ARGS__)
27
#define ds_exception_reterr(cond, err, ...) if (ds_exception(cond, err, __VA_ARGS__)) return err
28
#define ds_exception_retnull(cond, err, ...) if (ds_exception(cond, err, __VA_ARGS__)) return NULL
35
* Pushes message into the glib log file, this is maximal function which is
36
* expected to be called from various define macroses
38
* @param condition is message is shown only if condition is false
39
* @param log_domain is the log domain, usually G_LOG_DOMAIN
40
* @param log_level is the log level, either from GLogLevelFlags or a user-defined level, may indicate fatality
41
* @param file is source file where the event have occured
42
* @param func is function name where the event have occured
43
* @param line is source line where the event have occured
44
* @param service is the type of service which haev produced the event
45
* @param module is the type of module which have produced the event
46
* @param ptr is the object which have produced the event
47
* @param prefix is a message enclosing err and message (%s replaced with message and %iud... with error code)
48
* @param err is error code (0 - not an error, -1 - from errno)
49
* @param format is the message format. See the printf() documentation
51
int _ds_log_message(int condition, const gchar *log_domain, GLogLevelFlags log_levels, const char *file, const char *func, int line, const gchar *service, const gchar *module, void *ptr, gchar *prefix, int err, gchar *format, ...);
54
#define ds_log_message(condition, log_domain, log_levels, service, module, addr, prefix, err, ...) \
55
_ds_log_message(condition, log_domain, log_levels, __FILE__, __func__, __LINE__, service, module, addr, prefix, err, __VA_ARGS__)
57
/** Terminate application after printing message */
58
#define DS_LOG_FATAL_MESSAGE G_LOG_FLAG_FATAL
59
/** Free memory occupied by message if prefix is undefined or prefix otherwise */
60
#define DS_LOG_CLEAN_MESSAGE G_LOG_FLAG_RECURSION
61
/** Mask for selecting all levels */
62
#define DS_LOG_LEVEL_MASK G_LOG_LEVEL_MASK
64
/** Set required logger output and logging details (for all domains)
66
* @param log_level - maximal log detail
67
* @param sink - currently unsupported
69
void ds_configure_logger(GLogLevelFlags log_level, const char *sink);
71
/** Set required logging details (for all domains)
73
* @param log_level - maximal log detail
75
void ds_log_set_level(GLogLevelFlags log_level);
77
/** Switches on logging message timestmaps */
78
void ds_log_enable_timestamps();
80
/** Switches on logging threading information */
81
void ds_log_enable_threads();
83
/** Enables specific exception handler */
84
void ds_log_configure_exception_handler(GLogLevelFlags log_level, DSExceptionHandler handler, int log_exception_message);
90
#endif /* _DS_LOG_H */