- startet importing pluto ASN1 stuff
[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 ASN1,
60 LOGGER_CONTEXT_ROOF,
61 };
62
63
64 typedef struct logger_manager_t logger_manager_t;
65
66 /**
67 * @brief Class to manage logger_t objects.
68 *
69 * The logger manager manages all logger_t object in a list and
70 * allows their manipulation. Via a logger_context_t, the loglevel
71 * of a specific logging type can be adjusted at runtime.
72 * This class differs from others, as it has no constructor or destroy
73 * function. The one and only instance "logger_manager" is created at
74 * library start and destroyed at exit.
75 *
76 * @b Constructors:
77 * - none, logger_manager is an instance
78 *
79 * @see logger_t
80 *
81 * @ingroup utils
82 */
83 struct logger_manager_t {
84
85 /**
86 * @brief Gets a logger_t object for a specific logger context.
87 *
88 * @param this logger_manager_t object
89 * @param context logger_context to use the logger for
90 * @param name name for the new logger. Context name is already included
91 * and has not to be specified (so NULL is allowed)
92 * @return logger_t object
93 */
94 logger_t *(*get_logger) (logger_manager_t *this, logger_context_t context);
95
96 /**
97 * @brief Returns the set log_level of a specific context.
98 *
99 * @param this calling object
100 * @param context context to check level
101 * @return log_level for the given logger_context
102 */
103 log_level_t (*get_log_level) (logger_manager_t *this, logger_context_t context);
104
105 /**
106 * @brief Enables a logger level of a specific context.
107 *
108 * Use context ALL_LOGGERS to manipulate all loggers.
109 *
110 * @param this calling object
111 * @param context context to set level
112 * @param log_level logger level to eanble
113 */
114 void (*enable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
115
116 /**
117 * @brief Disables a logger level of a specific context.
118 *
119 * Use context ALL_LOGGERS to manipulate all loggers.
120 *
121 * @param this calling object
122 * @param context context to set level
123 * @param log_level logger level to disable
124 */
125 void (*disable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
126
127 /**
128 * @brief Sets the output of a logger.
129 *
130 * Use context ALL_LOGGERS to redirect all loggers.
131 *
132 * @param this calling object
133 * @param context context to set output
134 * @param log_level logger level to disable
135 */
136 void (*set_output) (logger_manager_t *this, logger_context_t context, FILE *output);
137 };
138
139 /**
140 * The single and global instance of the logger_manager
141 */
142 extern logger_manager_t *logger_manager;
143
144 #endif /*LOGGER_MANAGER_H_*/