../svn-commit.tmp
[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 *
72 * @b Constructors:
73 * - logger_manager_create()
74 *
75 * @see logger_t
76 *
77 * @ingroup utils
78 */
79 struct logger_manager_t {
80
81 /**
82 * @brief Gets a logger_t object for a specific logger context.
83 *
84 * @param this logger_manager_t object
85 * @param context logger_context to use the logger for
86 * @param name name for the new logger. Context name is already included
87 * and has not to be specified (so NULL is allowed)
88 * @return logger_t object
89 */
90 logger_t *(*get_logger) (logger_manager_t *this, logger_context_t context);
91
92 /**
93 * @brief Returns the set log_level of a specific context.
94 *
95 * @param this calling object
96 * @param context context to check level
97 * @return log_level for the given logger_context
98 */
99 log_level_t (*get_log_level) (logger_manager_t *this, logger_context_t context);
100
101 /**
102 * @brief Enables a logger level of a specific context.
103 *
104 * Use context ALL_LOGGERS to manipulate all loggers.
105 *
106 * @param this calling object
107 * @param context context to set level
108 * @param log_level logger level to eanble
109 */
110 void (*enable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
111
112 /**
113 * @brief Disables a logger level of a specific context.
114 *
115 * Use context ALL_LOGGERS to manipulate all loggers.
116 *
117 * @param this calling object
118 * @param context context to set level
119 * @param log_level logger level to disable
120 */
121 void (*disable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
122
123 /**
124 * @brief Sets the output of a logger.
125 *
126 * Use context ALL_LOGGERS to redirect all loggers.
127 *
128 * @param this calling object
129 * @param context context to set output
130 * @param log_level logger level to disable
131 */
132 void (*set_output) (logger_manager_t *this, logger_context_t context, FILE *output);
133
134 /**
135 * @brief Destroys a logger_manager_t object.
136 *
137 * All managed logger_t objects are also destroyed.
138 *
139 * @param this logger_manager_t object
140 */
141 void (*destroy) (logger_manager_t *this);
142 };
143
144 /**
145 * @brief Constructor to create a logger_manager_t object.
146 *
147 * @param default_log_level default log level for all context
148 * @return logger_manager_t object
149 *
150 * @ingroup utils
151 */
152 logger_manager_t *logger_manager_create(log_level_t default_log_level);
153
154
155 #endif /*LOGGER_MANAGER_H_*/