2 * Copyright (C) 2012 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * @defgroup logger logger
18 * @{ @ingroup listeners
24 typedef struct logger_t logger_t
;
29 * Logger interface, listens for log events on the bus.
31 * Calls to bus_t.log() are handled separately from calls to other functions.
32 * Logger functions may be called concurrently by multiple threads. Also
33 * recursive calls are not prevented, loggers that may cause recursive log
34 * messages are responsible to avoid infinite loops.
36 * Both the log() and the vlog() methods are optional to implement. With many
37 * loggers, using log() may be faster as printf() format substitution is done
38 * only once for all loggers.
43 * Log a debugging message.
45 * @param group kind of the signal (up, down, rekeyed, ...)
46 * @param level verbosity level of the signal
47 * @param thread ID of the thread raised this signal
48 * @param ike_sa IKE_SA associated to the event
49 * @param message log message
51 void (*log
)(logger_t
*this, debug_t group
, level_t level
, int thread
,
52 ike_sa_t
*ike_sa
, const char *message
);
55 * Log a debugging message with a format string.
57 * @note Calls to bus_t.log() are handled separately from calls to
58 * other functions. This callback may be called concurrently by
59 * multiple threads. Also recursive calls are not prevented, loggers that
60 * may cause recursive log messages are responsible to avoid infinite loops.
62 * @param group kind of the signal (up, down, rekeyed, ...)
63 * @param level verbosity level of the signal
64 * @param thread ID of the thread raised this signal
65 * @param ike_sa IKE_SA associated to the event
66 * @param fmt log message format string
67 * @param args variable arguments to format string
69 void (*vlog
)(logger_t
*this, debug_t group
, level_t level
, int thread
,
70 ike_sa_t
*ike_sa
, const char *fmt
, va_list args
);
73 * Get the desired log level for a debug group. This is called during
76 * If the desired log levels have changed, re-register the logger with
79 * @param group debug group
80 * @return max level to log (0..4) or -1 for none (see debug.h)
82 level_t (*get_level
)(logger_t
*this, debug_t group
);
85 #endif /** LOGGER_H_ @}*/