- code documentation cleaned
[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 typedef enum logger_context_t logger_context_t;
31
32 /**
33 * @brief Context of a specific logger
34 *
35 * @ingroup utils
36 */
37 enum logger_context_t {
38 PARSER,
39 GENERATOR,
40 IKE_SA,
41 IKE_SA_MANAGER,
42 MESSAGE,
43 THREAD_POOL,
44 WORKER,
45 SCHEDULER,
46 SENDER,
47 RECEIVER,
48 SOCKET,
49 TESTER,
50 DAEMON,
51 CONFIGURATION_MANAGER,
52 };
53
54 typedef struct logger_manager_t logger_manager_t;
55
56 /**
57 * Class to manage logger_t objects.
58 *
59 * @ingroup utils
60 */
61 struct logger_manager_t {
62
63 /**
64 * @brief Gets a logger_t object for a specific logger context.
65 *
66 * @warning Objects of type logger_t which are not destroyed over function
67 * #logger_manager_t.destroy_logger are destroyed in logger_managers
68 * destroy function. Don't use logger_t's own destroy function with
69 * managed logger_t objects.
70 *
71 * @param this logger_manager_t object
72 * @param context logger_context to use the logger for
73 * @param[out] logger pointer to a a place where the new logger is stored
74 * @param name name for the new logger. Context name is already included
75 * and has not to be specified (so NULL is allowed)
76 * @return
77 * - logger_t object
78 * - NULL if out of ressources
79 */
80 logger_t *(*create_logger) (logger_manager_t *this, logger_context_t context, char *name);
81
82
83 /**
84 * @brief Destroys a logger_t object which is not used anymore.
85 *
86 * @warning Objects of type logger_t which are not destroyed over function
87 * #logger_manager_t.destroy_logger are destroyed in logger_managers
88 * destroy function.
89 *
90 * @param this logger_manager_t object
91 * @param logger pointer to the logger which has to be destroyed
92 * @return - SUCCESS
93 * - OUT_OF_RES (when searching the specific logger_t object)
94 * - NOT_FOUND
95 */
96 status_t (*destroy_logger) (logger_manager_t *this,logger_t *logger);
97
98 /**
99 * Returns the set logger_level of a specific context or 0.
100 *
101 * @param this calling object
102 * @param context context to check level
103 * @return logger_level for the given logger_context
104 */
105 logger_level_t (*get_logger_level) (logger_manager_t *this, logger_context_t context);
106
107 /**
108 * Enables a logger_level of a specific context.
109 *
110 * @param this calling object
111 * @param context context to set level
112 * @param logger_level logger_level to eanble
113 * @return
114 * - SUCCESS
115 * - OUT_OF_RES
116 */
117 status_t (*enable_logger_level) (logger_manager_t *this, logger_context_t context,logger_level_t logger_level);
118
119
120 /**
121 * Disables a logger_level of a specific context.
122 *
123 * @param this calling object
124 * @param context context to set level
125 * @param logger_level logger_level to disable
126 * @return
127 * - SUCCESS
128 * - OUT_OF_RES
129 */
130 status_t (*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 * @return
140 * - SUCCESS in any case
141 */
142 status_t (*destroy) (logger_manager_t *this);
143 };
144
145 /**
146 * @brief Constructor to create a logger_manager_t object.
147 *
148 * @param default_log_level default log level for a context
149 * @return
150 * - logger_manager_t object
151 * - NULL if out of ressources
152 *
153 * @ingroup utils
154 */
155 logger_manager_t *logger_manager_create(logger_level_t default_log_level);
156
157
158 #endif /*LOGGER_MANAGER_H_*/