switch to cdbus code from libcdbus.so
[ladish.git] / log.h
blob18bd3545fc92a027eabb466ccb2ab0923778b3cf
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 #define ladish_log cdbus_log
54 #ifdef __cplusplus
55 extern "C"
56 #endif
57 void
58 ladish_log(
59 unsigned int level,
60 const char * file,
61 unsigned int line,
62 const char * func,
63 const char * format,
64 ...)
65 #if defined (__GNUC__)
66 __attribute__((format(printf, 5, 6)))
67 #endif
70 #define LADISH_LOG_LEVEL_DEBUG 0
71 #define LADISH_LOG_LEVEL_INFO 1
72 #define LADISH_LOG_LEVEL_WARN 2
73 #define LADISH_LOG_LEVEL_ERROR 3
74 #define LADISH_LOG_LEVEL_ERROR_PLAIN 4
76 #define log_debug(fmt, args...) ladish_log(LADISH_LOG_LEVEL_DEBUG, __FILE__, __LINE__, __func__, fmt, ## args)
77 #define log_info(fmt, args...) ladish_log(LADISH_LOG_LEVEL_INFO, __FILE__, __LINE__, __func__, fmt, ## args)
78 #define log_warn(fmt, args...) ladish_log(LADISH_LOG_LEVEL_WARN, __FILE__, __LINE__, __func__, fmt, ## args)
79 #define log_error(fmt, args...) ladish_log(LADISH_LOG_LEVEL_ERROR, __FILE__, __LINE__, __func__, fmt, ## args)
80 #define log_error_plain(fmt, args...) ladish_log(LADISH_LOG_LEVEL_ERROR_PLAIN, __FILE__, __LINE__, __func__, fmt, ## args)
82 #endif /* __LADISH_LOG__ */