LibInsane: /build/libinsane/src/libinsane/subprojects/libinsane/include/libinsane/log.h Source File

| LibInsane 1.0.10 Cross-platform Cross-API Cross-driver Cross-image-scanner Image Scan Library

Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1#ifndef __LIBINSANE_LOG_H
2#define __LIBINSANE_LOG_H
3
4 enum lis_log_level {
5 LIS_LOG_LVL_MIN = 0,
6 LIS_LOG_LVL_DEBUG = LIS_LOG_LVL_MIN,
7 LIS_LOG_LVL_INFO,
8 LIS_LOG_LVL_WARNING,
9 LIS_LOG_LVL_ERROR,
10 LIS_LOG_LVL_MAX = LIS_LOG_LVL_ERROR,
11};
12
13
18 typedef void (lis_log_callback)(enum lis_log_level lvl, const char *msg);
19
20
21 struct lis_log_callbacks {
22 lis_log_callback *callbacks[LIS_LOG_LVL_MAX + 1];
23};
24
25
34 extern void lis_set_log_callbacks(const struct lis_log_callbacks *callbacks);
35
36
37/* functions inside libinsane to log */
38
39 extern void lis_log(enum lis_log_level lvl, const char *file, int line, const char *func, const char *fmt, ...)
40#ifdef __GNUC__
41 __attribute__ ((format (printf, 5, 6)))
42#endif
43 ;
44
45#define lis_log_debug(...) lis_log(LIS_LOG_LVL_DEBUG, __FILE__, __LINE__, __func__, __VA_ARGS__);
46#define lis_log_info(...) lis_log(LIS_LOG_LVL_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__);
47#define lis_log_warning(...) lis_log(LIS_LOG_LVL_WARNING, __FILE__, __LINE__, __func__, __VA_ARGS__);
48#define lis_log_error(...) lis_log(LIS_LOG_LVL_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__);
49
50
51 extern void lis_log_raw(enum lis_log_level lvl, const char *msg);
52 extern void lis_log_reset(void);
53
54
59 lis_log_callback lis_log_stderr;
60
61
66 lis_log_callback lis_log_stdout;
67
68#endif
lis_log_raw
void lis_log_raw(enum lis_log_level lvl, const char *msg)
lis_set_log_callbacks
void lis_set_log_callbacks(const struct lis_log_callbacks *callbacks)
register callbacks that will be used to get back messages. Only one set of callbacks can be registere...
lis_log
void lis_log(enum lis_log_level lvl, const char *file, int line, const char *func, const char *fmt,...)
lis_log_stdout
lis_log_callback lis_log_stdout
default log callback provided for convenience. Will log to stdout.
Definition log.h:66
lis_log_callback
void lis_log_callback(enum lis_log_level lvl, const char *msg)
log callback
Definition log.h:18
lis_log_reset
void lis_log_reset(void)
lis_log_level
lis_log_level
Definition log.h:4
LIS_LOG_LVL_INFO
@ LIS_LOG_LVL_INFO
Definition log.h:7
LIS_LOG_LVL_ERROR
@ LIS_LOG_LVL_ERROR
Definition log.h:9
LIS_LOG_LVL_WARNING
@ LIS_LOG_LVL_WARNING
Definition log.h:8
LIS_LOG_LVL_DEBUG
@ LIS_LOG_LVL_DEBUG
Definition log.h:6
LIS_LOG_LVL_MIN
@ LIS_LOG_LVL_MIN
Definition log.h:5
LIS_LOG_LVL_MAX
@ LIS_LOG_LVL_MAX
Definition log.h:10
lis_log_stderr
lis_log_callback lis_log_stderr
default log callback provided for convenience. Will log to stderr.
Definition log.h:59
lis_log_callbacks
Definition log.h:21
lis_log_callbacks::callbacks
lis_log_callback * callbacks[LIS_LOG_LVL_MAX+1]
Definition log.h:22