Fix unused-parameter warnings in plain C code
[ladish.git] / log.h
blob136cf776a9279101f75df8380264fed9bfc96633
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2008, 2009, 2012 Nedko Arnaudov <nedko@arnaudov.name>
6 * Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com>
7 * Copyright (C) 2002 Robert Ham <rah@bash.sh>
9 **************************************************************************
10 * This file contains log macros
11 **************************************************************************
13 * LADI Session Handler is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * LADI Session Handler is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
25 * or write to the Free Software Foundation, Inc.,
26 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
29 #ifndef __LADISH_LOG_H__
30 #define __LADISH_LOG_H__
32 #define ANSI_BOLD_ON "\033[1m"
33 #define ANSI_BOLD_OFF "\033[22m"
34 #define ANSI_COLOR_RED "\033[31m"
35 #define ANSI_COLOR_YELLOW "\033[33m"
36 #define ANSI_RESET "\033[0m"
38 #include <stdio.h>
40 #include "config.h"
42 /* fallback for old gcc versions,
43 http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html */
44 #if __STDC_VERSION__ < 199901L
45 # if __GNUC__ >= 2
46 # define __func__ __FUNCTION__
47 # else
48 # define __func__ "<unknown>"
49 # endif
50 #endif
52 #ifdef __cplusplus
53 extern "C"
54 #endif
55 void
56 ladish_log(
57 unsigned int level,
58 const char * file,
59 unsigned int line,
60 const char * func,
61 const char * format,
62 ...)
63 #if defined (__GNUC__)
64 __attribute__((format(printf, 5, 6)))
65 #endif
68 #define LADISH_LOG_LEVEL_DEBUG 0
69 #define LADISH_LOG_LEVEL_INFO 1
70 #define LADISH_LOG_LEVEL_WARN 2
71 #define LADISH_LOG_LEVEL_ERROR 3
72 #define LADISH_LOG_LEVEL_ERROR_PLAIN 4
74 #define log_debug(fmt, args...) ladish_log(LADISH_LOG_LEVEL_DEBUG, __FILE__, __LINE__, __func__, fmt, ## args)
75 #define log_info(fmt, args...) ladish_log(LADISH_LOG_LEVEL_INFO, __FILE__, __LINE__, __func__, fmt, ## args)
76 #define log_warn(fmt, args...) ladish_log(LADISH_LOG_LEVEL_WARN, __FILE__, __LINE__, __func__, fmt, ## args)
77 #define log_error(fmt, args...) ladish_log(LADISH_LOG_LEVEL_ERROR, __FILE__, __LINE__, __func__, fmt, ## args)
78 #define log_error_plain(fmt, args...) ladish_log(LADISH_LOG_LEVEL_ERROR_PLAIN, __FILE__, __LINE__, __func__, fmt, ## args)
80 #endif /* __LADISH_LOG__ */