- split up in libstrong, charon, stroke, testing done
[strongswan.git] / Source / lib / utils / logger_manager.h
1 /**
2 * @file logger_manager.h
3 *
4 * @brief Interface of logger_manager_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef LOGGER_MANAGER_H_
24 #define LOGGER_MANAGER_H_
25
26 #include <pthread.h>
27
28 #include <utils/logger.h>
29
30
31 typedef enum logger_context_t logger_context_t;
32
33 /**
34 * @brief Context of a specific logger.
35 *
36 * @ingroup utils
37 */
38 enum logger_context_t {
39 ALL_LOGGERS = -1,
40 PARSER = 0,
41 GENERATOR,
42 IKE_SA,
43 IKE_SA_MANAGER,
44 CHILD_SA,
45 MESSAGE,
46 THREAD_POOL,
47 WORKER,
48 SCHEDULER,
49 SENDER,
50 RECEIVER,
51 SOCKET,
52 TESTER,
53 DAEMON,
54 CONFIG,
55 ENCRYPTION_PAYLOAD,
56 PAYLOAD,
57 DER_DECODER,
58 DER_ENCODER,
59 LOGGER_CONTEXT_ROOF,
60 };
61
62
63 typedef struct logger_manager_t logger_manager_t;
64
65 /**
66 * @brief Class to manage logger_t objects.
67 *
68 * The logger manager manages all logger_t object in a list and
69 * allows their manipulation. Via a logger_context_t, the loglevel
70 * of a specific logging type can be adjusted at runtime.
71 * This class differs from others, as it has no constructor or destroy
72 * function. The one and only instance "logger_manager" is created at
73 * library start and destroyed at exit.
74 *
75 * @b Constructors:
76 * - none, logger_manager is an instance
77 *
78 * @see logger_t
79 *
80 * @ingroup utils
81 */
82 struct logger_manager_t {
83
84 /**
85 * @brief Gets a logger_t object for a specific logger context.
86 *
87 * @param this logger_manager_t object
88 * @param context logger_context to use the logger for
89 * @param name name for the new logger. Context name is already included
90 * and has not to be specified (so NULL is allowed)
91 * @return logger_t object
92 */
93 logger_t *(*get_logger) (logger_manager_t *this, logger_context_t context);
94
95 /**
96 * @brief Returns the set log_level of a specific context.
97 *
98 * @param this calling object
99 * @param context context to check level
100 * @return log_level for the given logger_context
101 */
102 log_level_t (*get_log_level) (logger_manager_t *this, logger_context_t context);
103
104 /**
105 * @brief Enables a logger level of a specific context.
106 *
107 * Use context ALL_LOGGERS to manipulate all loggers.
108 *
109 * @param this calling object
110 * @param context context to set level
111 * @param log_level logger level to eanble
112 */
113 void (*enable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
114
115 /**
116 * @brief Disables a logger level of a specific context.
117 *
118 * Use context ALL_LOGGERS to manipulate all loggers.
119 *
120 * @param this calling object
121 * @param context context to set level
122 * @param log_level logger level to disable
123 */
124 void (*disable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
125
126 /**
127 * @brief Sets the output of a logger.
128 *
129 * Use context ALL_LOGGERS to redirect all loggers.
130 *
131 * @param this calling object
132 * @param context context to set output
133 * @param log_level logger level to disable
134 */
135 void (*set_output) (logger_manager_t *this, logger_context_t context, FILE *output);
136 };
137
138 /**
139 * The single and global instance of the logger_manager
140 */
141 extern logger_manager_t *logger_manager;
142
143 #endif /*LOGGER_MANAGER_H_*/