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