3
* @brief Prototypes for logging functions.
5
/* biosim - A simulator for the predator-prey relationship of aphids and
8
* Copyright (c) 2010, Tilman Blumenbach <tilman@ax86.net>
11
* Redistribution and use in source and binary forms, with or without
12
* modification, are permitted provided that the following conditions are
14
* - Redistributions of source code must retain the above copyright notice,
15
* this list of conditions and the following disclaimer.
16
* - Redistributions in binary form must reproduce the above copyright
17
* notice, this list of conditions and the following disclaimer in the
18
* documentation and/or other materials provided with the distribution.
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
24
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
28
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30
* THE POSSIBILITY OF SUCH DAMAGE.
37
* @brief Log a message and the file name / line number of origin to stderr.
39
* This macro takes a variable number of arguments which are passed to
40
* vfprintf(). That means \c fmt can be a format string.
42
* This is a wrapper for log_msg().
44
* @param lvl Log level for this message.
45
* @param fmt The message to log (format string).
47
#define LOGF_FILELINE( lvl, fmt, ... ) log_msg( lvl, "%s:%d: " fmt, \
48
__FILE__, __LINE__, __VA_ARGS__ )
51
* @brief Log a message and the file name / line number of origin to stderr.
53
* This macro is similar to LOGF_FILELINE(), but it does not take arguments
54
* to pass to vfprintf() (e. g. for conversion specifiers).
56
* This is a wrapper for log_msg().
58
* @param lvl Log level for this message.
59
* @param fmt The message to log.
61
#define LOG_FILELINE( lvl, fmt ) log_msg( lvl, "%s:%d: " fmt, \
65
* @brief The default log level to use if none is set explicitly by calling
68
#define LOG_DEFAULT_LVL LOG_ERROR
79
* @brief Print the last Windows API error to stderr.
80
* @param file Path to the file of origin (use __FILE__).
81
* @param line Line number of origin (use __LINE__).
83
void log_last_WinError( const char *file, unsigned int line );
87
* @brief Get the current log level.
88
* @return The current log level.
90
log_level log_get_level();
93
* @brief Set the log level.
95
* The log level determines which log messages are shown to the user.
96
* Messages with a log level higher than the specified one are suppressed.
98
* @param The log level to set.
100
void log_set_level( log_level newlvl );
103
* @brief Log a message to stderr.
105
* The macros LOGF_FILELINE() and LOG_FILELINE() pass the current file name
106
* and line number to this function and should be used most the time.
108
* This function takes a variable number of arguments which are passed to
109
* vfprintf(). That means \c fmt can be a format string.
111
* @param lvl The log level for the message.
112
* @param fmt The message to log (format string).
114
void log_msg( log_level lvl, const char *fmt, ... );
116
#endif /* ifndef LOG_H */