1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/**
* @file logger_manager.h
*
* @brief Interface of logger_manager_t.
*
*/
/*
* Copyright (C) 2005 Jan Hutter, Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef LOGGER_MANAGER_H_
#define LOGGER_MANAGER_H_
#include <pthread.h>
#include <utils/logger.h>
typedef enum logger_context_t logger_context_t;
/**
* @brief Context of a specific logger.
*
* @ingroup utils
*/
enum logger_context_t {
ALL_LOGGERS = -1,
PARSER = 0,
GENERATOR,
IKE_SA,
IKE_SA_MANAGER,
CHILD_SA,
MESSAGE,
THREAD_POOL,
WORKER,
SCHEDULER,
SENDER,
RECEIVER,
SOCKET,
TESTER,
DAEMON,
CONFIG,
ENCRYPTION_PAYLOAD,
PAYLOAD,
DER_DECODER,
DER_ENCODER,
ASN1,
LOGGER_CONTEXT_ROOF,
};
typedef struct logger_manager_t logger_manager_t;
/**
* @brief Class to manage logger_t objects.
*
* The logger manager manages all logger_t object in a list and
* allows their manipulation. Via a logger_context_t, the loglevel
* of a specific logging type can be adjusted at runtime.
* This class differs from others, as it has no constructor or destroy
* function. The one and only instance "logger_manager" is created at
* library start and destroyed at exit.
*
* @b Constructors:
* - none, logger_manager is an instance
*
* @see logger_t
*
* @ingroup utils
*/
struct logger_manager_t {
/**
* @brief Gets a logger_t object for a specific logger context.
*
* @param this logger_manager_t object
* @param context logger_context to use the logger for
* @param name name for the new logger. Context name is already included
* and has not to be specified (so NULL is allowed)
* @return logger_t object
*/
logger_t *(*get_logger) (logger_manager_t *this, logger_context_t context);
/**
* @brief Returns the set log_level of a specific context.
*
* @param this calling object
* @param context context to check level
* @return log_level for the given logger_context
*/
log_level_t (*get_log_level) (logger_manager_t *this, logger_context_t context);
/**
* @brief Enables a logger level of a specific context.
*
* Use context ALL_LOGGERS to manipulate all loggers.
*
* @param this calling object
* @param context context to set level
* @param log_level logger level to eanble
*/
void (*enable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
/**
* @brief Disables a logger level of a specific context.
*
* Use context ALL_LOGGERS to manipulate all loggers.
*
* @param this calling object
* @param context context to set level
* @param log_level logger level to disable
*/
void (*disable_log_level) (logger_manager_t *this, logger_context_t context,log_level_t log_level);
/**
* @brief Sets the output of a logger.
*
* Use context ALL_LOGGERS to redirect all loggers.
*
* @param this calling object
* @param context context to set output
* @param log_level logger level to disable
*/
void (*set_output) (logger_manager_t *this, logger_context_t context, FILE *output);
};
/**
* The single and global instance of the logger_manager
*/
extern logger_manager_t *logger_manager;
#endif /*LOGGER_MANAGER_H_*/
|