3b99e7dc1b71d79ac6e00018598861ef5af47568
[strongswan.git] / src / libcharon / bus / listeners / logger.h
1 /*
2 * Copyright (C) 2012 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 /**
17 * @defgroup logger logger
18 * @{ @ingroup listeners
19 */
20
21 #ifndef LOGGER_H_
22 #define LOGGER_H_
23
24 typedef struct logger_t logger_t;
25
26 #include <bus/bus.h>
27
28 /**
29 * Logger interface, listens for log events on the bus.
30 */
31 struct logger_t {
32
33 /**
34 * Log a debugging message.
35 *
36 * @note Calls to bus_t.log() are handled separately from calls to
37 * other functions. This callback may be called concurrently by
38 * multiple threads. Also recursive calls are not prevented, loggers that
39 * may cause recursive log messages are responsible to avoid infinite loops.
40 *
41 * @param group kind of the signal (up, down, rekeyed, ...)
42 * @param level verbosity level of the signal
43 * @param thread ID of the thread raised this signal
44 * @param ike_sa IKE_SA associated to the event
45 * @param message log message
46 */
47 void (*log)(logger_t *this, debug_t group, level_t level, int thread,
48 ike_sa_t *ike_sa, const char *message);
49
50 /**
51 * Get the desired log level for a debug group. This is called during
52 * registration.
53 *
54 * If the desired log levels have changed, re-register the logger with
55 * the bus.
56 *
57 * @param group debug group
58 * @return max level to log (0..4) or -1 for none (see debug.h)
59 */
60 level_t (*get_level)(logger_t *this, debug_t group);
61 };
62
63 #endif /** LOGGER_H_ @}*/