2 * @file logger_manager.h
4 * @brief Interface of logger_manager_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
23 #ifndef LOGGER_MANAGER_H_
24 #define LOGGER_MANAGER_H_
28 #include <utils/logger.h>
30 #define INITIAL_LOG_OUTPUT stdout
32 typedef enum logger_context_t logger_context_t
;
35 * @brief Context of a specific logger.
39 enum logger_context_t
{
67 typedef struct logger_manager_t logger_manager_t
;
70 * @brief Class to manage logger_t objects.
72 * The logger manager manages all logger_t object in a list and
73 * allows their manipulation. Via a logger_context_t, the loglevel
74 * of a specific logging type can be adjusted at runtime.
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.
80 * - none, logger_manager is the single instance
81 * use logger_manager_init/logger_manager_cleanup
87 struct logger_manager_t
{
90 * @brief Gets a logger_t object for a specific logger context.
92 * @param this logger_manager_t object
93 * @param context logger_context to use the logger for
94 * @param name name for the new logger. Context name is already included
95 * and has not to be specified (so NULL is allowed)
96 * @return logger_t object
98 logger_t
*(*get_logger
) (logger_manager_t
*this, logger_context_t context
);
101 * @brief Returns the set log_level of a specific context.
103 * @param this calling object
104 * @param context context to check level
105 * @return log_level for the given logger_context
107 log_level_t (*get_log_level
) (logger_manager_t
*this, logger_context_t context
);
110 * @brief Enables a logger level of a specific context.
112 * Use context ALL_LOGGERS to manipulate all loggers.
114 * @param this calling object
115 * @param context context to set level
116 * @param log_level logger level to eanble
118 void (*enable_log_level
) (logger_manager_t
*this, logger_context_t context
,log_level_t log_level
);
121 * @brief Disables a logger level of a specific context.
123 * Use context ALL_LOGGERS to manipulate all loggers.
125 * @param this calling object
126 * @param context context to set level
127 * @param log_level logger level to disable
129 void (*disable_log_level
) (logger_manager_t
*this, logger_context_t context
,log_level_t log_level
);
132 * @brief Sets the output of a logger.
134 * Use context ALL_LOGGERS to redirect all loggers.
136 * @param this calling object
137 * @param context context to set output
138 * @param log_level logger level to disable
140 void (*set_output
) (logger_manager_t
*this, logger_context_t context
, FILE *output
);
144 * The single and global instance of the logger_manager
146 extern logger_manager_t
*logger_manager
;
149 * Initialize the logger manager with all its logger.
150 * Has to be called before logger_manager is accessed.
152 void logger_manager_init();
155 * Free any resources hold by the logger manager. Do
156 * not access logger_manager after this call.
158 void logger_manager_cleanup();
160 #endif /*LOGGER_MANAGER_H_*/