Must use (void) instead of () for function declarations.
[lwes-journaller.git] / src / log.h
blob76fbc4ef6d3ee7559b4b8b7cfa042cde10877235
1 /*======================================================================*
2 * Copyright (C) 2008 Light Weight Event System *
3 * All rights reserved. *
4 * *
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. *
9 * *
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. *
14 * *
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 *======================================================================*/
20 #ifndef LOG_H
21 #define LOG_H
23 #include "config.h"
25 #include <stdarg.h>
27 #ifdef HAVE_SYS_TYPES_H
28 #include <sys/types.h>
29 #endif
31 #ifdef HAVE_SYSLOG_H
32 #include <syslog.h>
33 #else
34 #define LOG_EMERG 0 /* system is unusable */
35 #define LOG_ALERT 1 /* action must be taken immediately */
36 #define LOG_CRIT 2 /* critical conditions */
37 #define LOG_ERR 3 /* error conditions */
38 #define LOG_WARNING 4 /* warning conditions */
39 #define LOG_NOTICE 5 /* normal but significant condition */
40 #define LOG_INFO 6 /* informational */
41 #define LOG_DEBUG 7 /* debug-level messages */
42 #endif
44 enum {
45 off, error, warning, info, progress
48 #define LOG_MASK_OFF (1<<off)
49 #define LOG_MASK_ERROR (1<<error)
50 #define LOG_MASK_WARNING (1<<warning)
51 #define LOG_MASK_INFO (1<<info)
52 #define LOG_MASK_PROGRESS (1<<progress)
54 /*! \file log.h
55 * \brief Functions for logging within the journaller
58 /*! \brief Logs a message
60 * This method is not usually called directly, instead one of the
61 * logging macros is used.
63 * \param[in] level the syslog level to log
64 * \param[in] fname the filename logging this message
65 * \param[in] lineno the line number of the file logging this message
66 * \param[in] format the format of the message
67 */
68 void log_msg(int level, const char *fname, int lineno, const char* format, ...);
69 void log_get_level_string(char* str, int len);
71 #if defined(HAVE_GCC_MACRO_VARARGS) || defined(HAVE_GNUC_C_VARARGS)
72 #define LOG_ER(args...) log_msg(LOG_MASK_ERROR, __FILE__, __LINE__, args)
73 #define LOG_WARN(args...) log_msg(LOG_MASK_WARNING, __FILE__, __LINE__, args)
74 #define LOG_INF(args...) log_msg(LOG_MASK_INFO, __FILE__, __LINE__, args)
75 #define LOG_PROG(args...) log_msg(LOG_MASK_PROGRESS, __FILE__, __LINE__, args)
76 #elif defined(HAVE_ISO_MACRO_VARARGS) || defined(HAVE_ISO_C_VARARGS)
77 #define LOG_ER(...) log_msg(LOG_MASK_ERROR, __FILE__, __LINE__, __VA_ARGS__)
78 #define LOG_WARN(...) log_msg(LOG_MASK_WARNING, __FILE__, __LINE__, __VA_ARGS__)
79 #define LOG_INF(...) log_msg(LOG_MASK_INFO, __FILE__, __LINE__, __VA_ARGS__)
80 #define LOG_PROG(...) log_msg(LOG_MASK_PROGRESS, __FILE__, __LINE__, __VA_ARGS__)
81 #else
82 #error You must have some type (either ISO-C99 or GCC style) of variable argument list for macros.
83 #endif
85 #endif