]> git.ipfire.org Git - people/ms/strongswan.git/blame - programs/charon/lib/utils/logger_manager.h
- import of strongswan-2.7.0
[people/ms/strongswan.git] / programs / charon / lib / utils / logger_manager.h
CommitLineData
ffd555f5
JH
1/**
2 * @file logger_manager.h
3 *
caf2a93a 4 * @brief Interface of logger_manager_t.
ffd555f5
JH
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
021c2322 28#include <utils/logger.h>
ffd555f5 29
8bc96e08 30#define INITIAL_LOG_OUTPUT stdout
d794bcdb 31
5796aa16
MW
32typedef enum logger_context_t logger_context_t;
33
ffd555f5 34/**
f673471b 35 * @brief Context of a specific logger.
caf2a93a
JH
36 *
37 * @ingroup utils
ffd555f5 38 */
5796aa16 39enum logger_context_t {
efadbf79 40 ALL_LOGGERS = -1,
dec59822 41 PARSER = 0,
ffd555f5
JH
42 GENERATOR,
43 IKE_SA,
9c6340cd 44 IKE_SA_MANAGER,
aeda79ff 45 CHILD_SA,
ffd555f5 46 MESSAGE,
96d72d32 47 THREAD_POOL,
41fc4f74
MW
48 WORKER,
49 SCHEDULER,
50 SENDER,
51 RECEIVER,
52 SOCKET,
ffd555f5 53 TESTER,
f4358cb2 54 DAEMON,
8a491129 55 CONFIG,
ccf783d2 56 ENCRYPTION_PAYLOAD,
dec59822 57 PAYLOAD,
9c781c15
MW
58 DER_DECODER,
59 DER_ENCODER,
b5cb0210 60 ASN1,
8f1c27ba 61 XFRM,
9d7597bb 62 LEAK_DETECT,
dec59822 63 LOGGER_CONTEXT_ROOF,
5796aa16
MW
64};
65
d794bcdb 66
5796aa16 67typedef struct logger_manager_t logger_manager_t;
ffd555f5 68
ffd555f5 69/**
f673471b
MW
70 * @brief Class to manage logger_t objects.
71 *
d794bcdb 72 * The logger manager manages all logger_t object in a list and
f673471b
MW
73 * allows their manipulation. Via a logger_context_t, the loglevel
74 * of a specific logging type can be adjusted at runtime.
5113680f
MW
75 * This class differs from others, as it has no constructor or destroy
76 * function. The one and only instance "logger_manager" is created at
77 * library start and destroyed at exit.
f673471b
MW
78 *
79 * @b Constructors:
8bc96e08 80 * - none, logger_manager is the single instance
6b3292da 81 * use logger_manager_init/logger_manager_cleanup
f673471b
MW
82 *
83 * @see logger_t
caf2a93a
JH
84 *
85 * @ingroup utils
ffd555f5 86 */
5796aa16 87struct logger_manager_t {
ffd555f5
JH
88
89 /**
90 * @brief Gets a logger_t object for a specific logger context.
ffd555f5
JH
91 *
92 * @param this logger_manager_t object
caf2a93a 93 * @param context logger_context to use the logger for
ffd555f5 94 * @param name name for the new logger. Context name is already included
caf2a93a 95 * and has not to be specified (so NULL is allowed)
d048df5c 96 * @return logger_t object
ffd555f5 97 */
dec59822 98 logger_t *(*get_logger) (logger_manager_t *this, logger_context_t context);
ffd555f5
JH
99
100 /**
efadbf79 101 * @brief Returns the set log_level of a specific context.
caf2a93a 102 *
ffd555f5
JH
103 * @param this calling object
104 * @param context context to check level
dec59822 105 * @return log_level for the given logger_context
ffd555f5 106 */
dec59822 107 log_level_t (*get_log_level) (logger_manager_t *this, logger_context_t context);
ffd555f5
JH
108
109 /**
efadbf79
MW
110 * @brief Enables a logger level of a specific context.
111 *
112 * Use context ALL_LOGGERS to manipulate all loggers.
caf2a93a 113 *
ffd555f5
JH
114 * @param this calling object
115 * @param context context to set level
dec59822 116 * @param log_level logger level to eanble
ffd555f5 117 */
dec59822 118 void (*enable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
efadbf79 119
ffd555f5 120 /**
efadbf79
MW
121 * @brief Disables a logger level of a specific context.
122 *
123 * Use context ALL_LOGGERS to manipulate all loggers.
caf2a93a 124 *
ffd555f5
JH
125 * @param this calling object
126 * @param context context to set level
efadbf79 127 * @param log_level logger level to disable
ffd555f5 128 */
dec59822 129 void (*disable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
efadbf79
MW
130
131 /**
132 * @brief Sets the output of a logger.
133 *
134 * Use context ALL_LOGGERS to redirect all loggers.
135 *
136 * @param this calling object
137 * @param context context to set output
138 * @param log_level logger level to disable
139 */
140 void (*set_output) (logger_manager_t *this, logger_context_t context, FILE *output);
ffd555f5
JH
141};
142
143/**
5113680f 144 * The single and global instance of the logger_manager
ffd555f5 145 */
5113680f 146extern logger_manager_t *logger_manager;
ffd555f5 147
fcfeb322
MW
148/**
149 * Initialize the logger manager with all its logger.
150 * Has to be called before logger_manager is accessed.
151 */
6b3292da
MW
152void logger_manager_init();
153
fcfeb322
MW
154/**
155 * Free any resources hold by the logger manager. Do
156 * not access logger_manager after this call.
157 */
6b3292da
MW
158void logger_manager_cleanup();
159
ffd555f5 160#endif /*LOGGER_MANAGER_H_*/