1 /*======================================================================*
2 * Copyright (C) 2008 Light Weight Event System *
3 * All rights reserved. *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
18 * Boston, MA 02110-1301 USA. *
19 *======================================================================*/
27 #ifdef HAVE_SYS_TYPES_H
28 #include <sys/types.h>
32 LOG_OFF
, LOG_ERROR
, LOG_WARNING
, LOG_INFO
, LOG_PROGRESS
36 LOG_MASK_OFF
= (1<<LOG_OFF
),
37 LOG_MASK_ERROR
= (1<<LOG_ERROR
),
38 LOG_MASK_WARNING
= (1<<LOG_WARNING
),
39 LOG_MASK_INFO
= (1<<LOG_INFO
),
40 LOG_MASK_PROGRESS
= (1<<LOG_PROGRESS
)
44 * \brief Functions for logging within the journaller
47 /*! \brief Logs a message
49 * This method is not usually called directly, instead one of the
50 * logging macros is used.
52 * \param[in] time the UTC time of the log line
53 * \param[in] level the level to log
54 * \param[in] fname the filename logging this message
55 * \param[in] lineno the line number of the file logging this message
56 * \param[in] format the format of the message
58 void log_msg(log_level_t level
, const char *fname
, int lineno
, const char* format
, ...);
59 void log_get_mask_string(char* str
, int len
);
61 #if defined(HAVE_GCC_MACRO_VARARGS) || defined(HAVE_GNUC_C_VARARGS)
62 #define LOG_ER(args...) log_msg(LOG_ERROR, __FILE__, __LINE__, args)
63 #define LOG_WARN(args...) log_msg(LOG_WARNING, __FILE__, __LINE__, args)
64 #define LOG_INF(args...) log_msg(LOG_INFO, __FILE__, __LINE__, args)
65 #define LOG_PROG(args...) log_msg(LOG_PROGRESS, __FILE__, __LINE__, args)
66 #elif defined(HAVE_ISO_MACRO_VARARGS) || defined(HAVE_ISO_C_VARARGS)
67 #define LOG_ER(...) log_msg(LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__)
68 #define LOG_WARN(...) log_msg(LOG_WARNING, __FILE__, __LINE__, __VA_ARGS__)
69 #define LOG_INF(...) log_msg(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
70 #define LOG_PROG(...) log_msg(LOG_PROGRESS, __FILE__, __LINE__, __VA_ARGS__)
72 #error You must have some type (either ISO-C99 or GCC style) of variable argument list for macros.