4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
30 * All Rights Reserved.
33 * \brief Logging system module.
35 * This module implement a simple interface to use the multi level
37 * The log message have the priority order, like this:
39 * - error message (most hight)
41 * - info message (most low)
43 * With this priority system we can log only the message that have egual or major
44 * priority than log level that you has been configurate. Further you can have a
45 * differ log level for each module that you want. To do this you just need to
46 * define LOG_LEVEL in cfg of select module.
47 * When you set a log level, the system logs only the message that have priority
48 * egual or major that you have define, but the other logs function are not include
49 * at compile time, so all used logs function are linked, but the other no.
51 * To use logging system you should include this module in your drive and use
52 * a LOG_ERROR, LOG_WARNING and LOG_INFO macros to set the level log of the message.
53 * Then you should define a LOG_LEVEL and LOG_VERBOSE costant in your
54 * cfg/cfg_<your_module_name>.h using the follow police:
59 * * Logging level definition.
61 * * Use 0 to log only the error messages
62 * * Use 1 to log the error and warning messages
63 * * Use 2 to log all messages
65 * #define <module_name>_LOG_LEVEL 2
68 * * Set logging verbosity.
70 * * If verbose is zero print short log messages.
72 * #define <module_name>_LOG_VERBOSE 1
74 * // Define logging setting (for cfg/log.h module).
75 * #define LOG_LEVEL <module_name>_LOG_LEVEL
76 * #define LOG_VERBOSE <module_name>_LOG_VERBOSE
80 * if you include a log.h module without define the LOG_LEVEL and LOG_VERBOSE
81 * macros, the module use the default setting (see below).
83 * WARNING: when use the log.h module, and you want to set a your log level
84 * make sure to include this module after a cfg_<module_name>.h, because the
85 * LOG_LEVEL and LOG_VERBOSE macros must be define before to include log module,
86 * otherwise the log module use a default settings.
90 * \author Daniele Basile <asterix@develer.com>
96 #include <cfg/debug.h>
98 // Use a default setting if nobody have define a log level
100 #define LOG_LEVEL DBG_LOG_ERROR
103 // Use a default setting if nobody have define a log verbosity
105 #define LOG_VERBOSE DBG_LOG_SILENT
110 * Use this macro to print error messages. This log level have hight priority,
111 * that means the error messages are always printed, if debug is enable.
113 #define LOG_ERROR(str,...) DBG_ERROR(LOG_LEVEL, LOG_VERBOSE, str, ## __VA_ARGS__)
116 * Log message level select.
117 * When you choose a log level messages you choose
118 * also which print function are linked.
119 * If you choose a low level of log you link all log function (error, warning and info),
120 * but if choose a hight level you link only that have the priority egual or hight.
121 * The priority level go from error (most hight) to info (most low) (see cfg/debug.h
125 #if (LOG_LEVEL <= DBG_LOG_INFO)
126 #define LOG_WARNING(str,...) DBG_WARNING(LOG_LEVEL, LOG_VERBOSE, str, ## __VA_ARGS__)
127 #define LOG_INFO(str,...) DBG_INFO(LOG_LEVEL, LOG_VERBOSE, str, ## __VA_ARGS__)
129 #elif (LOG_LEVEL <= DBG_LOG_WARNING)
130 #define LOG_WARNING(str,...) DBG_WARNING(LOG_LEVEL, LOG_VERBOSE, str, ## __VA_ARGS__)
131 #define LOG_INFO(str,...) /* Nothing */
133 #else /* LOG_LEVEL <= DBG_LOG_ERROR */
134 #define LOG_WARNING(str,...) /* Nothing */
135 #define LOG_INFO(str,...) /* Nothing */
139 #endif /* CFG_LOG_H */