2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 01:51:51 +00:00
criu/include/log.h
Cyrill Gorcunov 7aa8e4b6e2 log: log-engine slight redesign
The messages are filtered by their type

    LOG_MSG     - plain messages, they escape any (!) log level
                  filtration and go to stdout
    LOG_ERROR   - error messages
    LOG_WARN    - warning messages
    LOG_INFO    - informative messages
    LOG_DEBUG   - debug messages

By default the LOG_WARN log level is used, thus LOG_INFO
and LOG_DEBUG messages will not appear in output stream.

pr_panic helper was replaced with pr_err, pr_warning
shorthanded to pr_warn and old printk if rather pr_msg
now.

Because we share messages between "show" and "dump" actions,
before the "show" action proceed we need to tune up
log level and set it to LOG_INFO.

Also note that printing of VMA and siginfo now
became LOG_INFO messages, it was not that correct
to print them regardless the log level.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-02 01:05:43 +04:00

39 lines
1.1 KiB
C

#ifndef LOG_H__
#define LOG_H__
extern int log_init(const char *output);
extern void log_fini(void);
extern int log_get_fd(void);
extern void log_set_loglevel(unsigned int loglevel);
extern void print_on_level(unsigned int loglevel, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
#define LOG_MSG (0) /* Print message regardless of log level */
#define LOG_ERROR (1) /* Errors only, when we're in trouble */
#define LOG_WARN (2) /* Warnings, dazen and confused but trying to continue */
#define LOG_INFO (3) /* Informative, everything is fine */
#define LOG_DEBUG (4) /* Debug only */
#define pr_msg(fmt, ...) \
print_on_level(LOG_MSG, fmt, ##__VA_ARGS__)
#define pr_info(fmt, ...) \
print_on_level(LOG_INFO, fmt, ##__VA_ARGS__)
#define pr_err(fmt, ...) \
print_on_level(LOG_ERROR, "Error (%s:%d): " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define pr_warn(fmt, ...) \
print_on_level(LOG_WARN, "Warn (%s:%d): " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define pr_debug(fmt, ...) \
print_on_level(LOG_DEBUG, fmt, ##__VA_ARGS__)
#define pr_perror(fmt, ...) \
pr_err(fmt ": %m\n", ##__VA_ARGS__)
#endif /* LOG_H__ */