]> git.ipfire.org Git - thirdparty/strongswan.git/blame - src/libcharon/bus/listeners/logger.h
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libcharon / bus / listeners / logger.h
CommitLineData
0e474f91
TB
1/*
2 * Copyright (C) 2012 Tobias Brunner
19ef2aec
TB
3 *
4 * Copyright (C) secunet Security Networks AG
0e474f91
TB
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17/**
18 * @defgroup logger logger
19 * @{ @ingroup listeners
20 */
21
22#ifndef LOGGER_H_
23#define LOGGER_H_
24
25typedef struct logger_t logger_t;
26
27#include <bus/bus.h>
28
29/**
30 * Logger interface, listens for log events on the bus.
5f55fd6e
MW
31 *
32 * Calls to bus_t.log() are handled separately from calls to other functions.
33 * Logger functions may be called concurrently by multiple threads. Also
34 * recursive calls are not prevented, loggers that may cause recursive log
35 * messages are responsible to avoid infinite loops.
36 *
37 * Both the log() and the vlog() methods are optional to implement. With many
38 * loggers, using log() may be faster as printf() format substitution is done
39 * only once for all loggers.
0e474f91
TB
40 */
41struct logger_t {
42
43 /**
44 * Log a debugging message.
45 *
5f55fd6e
MW
46 * @param group kind of the signal (up, down, rekeyed, ...)
47 * @param level verbosity level of the signal
48 * @param thread ID of the thread raised this signal
49 * @param ike_sa IKE_SA associated to the event
50 * @param message log message
51 */
52 void (*log)(logger_t *this, debug_t group, level_t level, int thread,
53 ike_sa_t *ike_sa, const char *message);
54
55 /**
56 * Log a debugging message with a format string.
57 *
ead92870
TB
58 * @note Calls to bus_t.log() are handled separately from calls to
59 * other functions. This callback may be called concurrently by
60 * multiple threads. Also recursive calls are not prevented, loggers that
61 * may cause recursive log messages are responsible to avoid infinite loops.
0e474f91
TB
62 *
63 * @param group kind of the signal (up, down, rekeyed, ...)
64 * @param level verbosity level of the signal
65 * @param thread ID of the thread raised this signal
66 * @param ike_sa IKE_SA associated to the event
5f55fd6e
MW
67 * @param fmt log message format string
68 * @param args variable arguments to format string
0e474f91 69 */
5f55fd6e
MW
70 void (*vlog)(logger_t *this, debug_t group, level_t level, int thread,
71 ike_sa_t *ike_sa, const char *fmt, va_list args);
0e474f91 72
ead92870
TB
73 /**
74 * Get the desired log level for a debug group. This is called during
75 * registration.
76 *
77 * If the desired log levels have changed, re-register the logger with
78 * the bus.
79 *
80 * @param group debug group
81 * @return max level to log (0..4) or -1 for none (see debug.h)
82 */
83 level_t (*get_level)(logger_t *this, debug_t group);
0e474f91
TB
84};
85
86#endif /** LOGGER_H_ @}*/