New logging macros

This commit is only to introduce new logging macros.

The current implementation is such that a statement like:

    MAXSCALE_NOTICE("Refreshing configuration following SIGHUP\n");

is equivalent with

    LOGIF(LM, (skygw_log_write(
                LOGFILE_MESSAGE,
                "Refreshing configuration following SIGHUP\n")));

The actual implementation will later be changed as the logging
mechanism itself is changed.

The names of the macros are now according to the levels of syslog
and currently the mapping is like:

    MAXSCALE_ERROR   (Syslog LOG_ERR)     -> LOGFILE_ERROR
    MAXSCALE_WARNING (Syslog LOG_WARNING) -> LOGFILE_ERROR
    MAXSCALE_NOTICE  (Syslof LOG_NOTICE)  -> LOGFILE_MESSAGE
    MAXSCALE_INFO    (Syslog LOG_INFO)    -> LOGFILE_TRACE
    MAXSCALE_DEBUG   (Syslog LOG_DEBUG)   -> LOGFILE_DEBUG

When log manager is changed to deal "natively" with syslog levels
this mapping will disappear of course.
This commit is contained in:
Johan Wikman
2015-10-23 13:32:42 +03:00
parent 846816a851
commit 4c0406a69c

View File

@ -182,4 +182,28 @@ const char* get_err_prefix_default(void);
const char* get_err_suffix_default(void);
const char* get_logpath_default(void);
/**
* Helper, not to be called directly.
*/
#define MAXSCALE_MESSAGE_FLUSH(id, format, ...)\
do { if (LOG_IS_ENABLED(id)) { skygw_log_write_flush(id, format, ##__VA_ARGS__); } } while (false)
/**
* Helper, not to be called directly.
*/
#define MAXSCALE_MESSAGE(id, format, ...)\
do { if (LOG_IS_ENABLED(id)) { skygw_log_write(id, format, ##__VA_ARGS__); } } while (false)
/**
* Log an error, warning, notice, info, or debug message.
*
* @param format The printf format of the message.
* @param ... Arguments, depending on the format.
*/
#define MAXSCALE_ERROR(format, ...) MAXSCALE_MESSAGE_FLUSH(LOGFILE_ERROR, format, ##__VA_ARGS__)
#define MAXSCALE_WARNING(format, ...) MAXSCALE_MESSAGE(LOGFILE_ERROR, format, ##__VA_ARGS__)
#define MAXSCALE_NOTICE(format, ...) MAXSCALE_MESSAGE(LOGFILE_MESSAGE, format, ##__VA_ARGS__)
#define MAXSCALE_INFO(format, ...) MAXSCALE_MESSAGE(LOGFILE_TRACE, format, ##__VA_ARGS__)
#define MAXSCALE_DEBUG(format, ...) MAXSCALE_MESSAGE(LOGFILE_DEBUG, format, ##__VA_ARGS__)
#endif /** LOG_MANAGER_H */