- key derivation for child_sa works
[strongswan.git] / Source / charon / 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 PARSER,
40 GENERATOR,
41 IKE_SA,
42 IKE_SA_MANAGER,
43 CHILD_SA,
44 MESSAGE,
45 THREAD_POOL,
46 WORKER,
47 SCHEDULER,
48 SENDER,
49 RECEIVER,
50 SOCKET,
51 TESTER,
52 DAEMON,
53 CONFIGURATION_MANAGER,
54 ENCRYPTION_PAYLOAD,
55 };
56
57
58 typedef struct logger_manager_t logger_manager_t;
59
60 /**
61 * @brief Class to manage logger_t objects.
62 *
63 * The logger manager manages all logger_t object in a list and
64 * allows their manipulation. Via a logger_context_t, the loglevel
65 * of a specific logging type can be adjusted at runtime.
66 *
67 * @b Constructors:
68 * - logger_manager_create()
69 *
70 * @see logger_t
71 *
72 * @ingroup utils
73 */
74 struct logger_manager_t {
75
76 /**
77 * @brief Gets a logger_t object for a specific logger context.
78 *
79 * @warning Objects of type logger_t which are not destroyed over function
80 * #logger_manager_t.destroy_logger are destroyed in logger_managers
81 * destroy function. Don't use logger_t's own destroy function with
82 * managed logger_t objects.
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 *(*create_logger) (logger_manager_t *this, logger_context_t context, char *name);
91
92 /**
93 * @brief Destroys a logger_t object which is not used anymore.
94 *
95 * Objects of type logger_t which are not destroyed over function
96 * #logger_manager_t.destroy_logger are destroyed in logger_managers
97 * destroy function.
98 *
99 * @param this logger_manager_t object
100 * @param logger pointer to the logger which has to be destroyed
101 */
102 void (*destroy_logger) (logger_manager_t *this,logger_t *logger);
103
104 /**
105 * Returns the set logger_level of a specific context or 0.
106 *
107 * @param this calling object
108 * @param context context to check level
109 * @return logger_level for the given logger_context
110 */
111 logger_level_t (*get_logger_level) (logger_manager_t *this, logger_context_t context);
112
113 /**
114 * Enables a logger level of a specific context.
115 *
116 * @param this calling object
117 * @param context context to set level
118 * @param logger_level logger level to eanble
119 */
120 void (*enable_logger_level) (logger_manager_t *this, logger_context_t context,logger_level_t logger_level);
121
122
123 /**
124 * Disables a logger level of a specific context.
125 *
126 * @param this calling object
127 * @param context context to set level
128 * @param logger_level logger level to disable
129 */
130 void (*disable_logger_level) (logger_manager_t *this, logger_context_t context,logger_level_t logger_level);
131
132
133 /**
134 * @brief Destroys a logger_manager_t object.
135 *
136 * All remaining managed logger_t objects are also destroyed.
137 *
138 * @param this logger_manager_t object
139 */
140 void (*destroy) (logger_manager_t *this);
141 };
142
143 /**
144 * @brief Constructor to create a logger_manager_t object.
145 *
146 * @param default_log_level default log level for all context
147 * @return logger_manager_t object
148 *
149 * @ingroup utils
150 */
151 logger_manager_t *logger_manager_create(logger_level_t default_log_level);
152
153
154 #endif /*LOGGER_MANAGER_H_*/