59c88d109e68b08ed1a356fe30c129a095df325c
[strongswan.git] / Source / charon / logger_manager.h
1 /**
2 * @file logger_manager.h
3 *
4 * @brief Logger manager. Manages globaly all logger objects
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 "logger.h"
29
30 /**
31 * @brief Context of a specific logger
32 */
33 typedef enum logger_context_e logger_context_t;
34
35 enum logger_context_e{
36 PARSER,
37 GENERATOR,
38 IKE_SA,
39 MESSAGE,
40 THREAD_POOL,
41 WORKER_THREAD,
42 EVENT_THREAD,
43 SENDER_THREAD,
44 RECEIVER_THREAD,
45 TESTER,
46 };
47
48
49 /**
50 * @brief The logger_manager_t object
51 */
52 typedef struct logger_manager_s logger_manager_t;
53
54 struct logger_manager_s {
55
56 /**
57 * @brief Gets a logger_t object for a specific logger context.
58 *
59 * @warning logger_t objects which are not destroyed over function
60 * #logger_manager_s.destroy_logger are destroyed in logger_managers
61 * destroy function. Don't use logger_t's own destroy function with
62 * managed logger_t objects.
63 *
64 * @param this logger_manager_t object
65 * @param context logger_context to use the logger for.
66 * @param[out] logger pointer to a a place where the new logger is stored
67 * @param name name for the new logger. Context name is already included
68 * and has not to be specified.
69 * @return
70 * - SUCCESS
71 * - OUT_OF_RES
72 */
73 status_t (*get_logger) (logger_manager_t *this, logger_context_t context, logger_t **logger, char *name);
74
75
76 /**
77 * @brief Destroys a logger_t object which is not used anymore
78 *
79 * @warning logger_t objects which are not destroyed over function
80 * #logger_manager_s.destroy_logger are destroyed in logger_managers
81 * destroy function.
82 *
83 * @param this logger_manager_t object
84 * @param logger pointer to the logger which has to be destroyed
85 * @return
86 * - SUCCESS
87 * - OUT_OF_RES
88 * - NOT_FOUND
89 */
90 status_t (*destroy_logger) (logger_manager_t *this,logger_t *logger);
91
92 /**
93 * Returns the set logger_level of a specific context or 0.
94 * @param this calling object
95 * @param context context to check level
96 * @return logger_level for the given logger_context
97 */
98 logger_level_t (*get_logger_level) (logger_manager_t *this, logger_context_t context);
99
100 /**
101 * Enables a logger_level of a specific context.
102 * @param this calling object
103 * @param context context to set level
104 * @param logger_level logger_level to eanble
105 * @return SUCCESS
106 */
107 status_t (*enable_logger_level) (logger_manager_t *this, logger_context_t context,logger_level_t logger_level);
108
109
110 /**
111 * Disables a logger_level of a specific context.
112 * @param this calling object
113 * @param context context to set level
114 * @param logger_level logger_level to disable
115 * @return SUCCESS
116 */
117 status_t (*disable_logger_level) (logger_manager_t *this, logger_context_t context,logger_level_t logger_level);
118
119
120 /**
121 * @brief destroys a logger_manager_t object.
122 *
123 * @param this logger_manager_t object
124 * @return
125 * - SUCCESS in any case
126 */
127 status_t (*destroy) (logger_manager_t *this);
128 };
129
130 /**
131 * @brief Constructor to create a logger_manager_t object.
132 *
133 * @param default_log_level default log level for a context
134 * @return logger_manager_t object or NULL if failed
135 *
136 */
137 logger_manager_t *logger_manager_create(logger_level_t default_log_level);
138
139
140 #endif /*LOGGER_MANAGER_H_*/