]>
git.ipfire.org Git - thirdparty/strongswan.git/blob - programs/charon/lib/utils/logger.h
4 * @brief Interface of logger_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
30 typedef enum log_level_t log_level_t
;
33 * @brief Log Levels supported by the logger object.
35 * Logleves are devided in two different kinds:
36 * - levels to specify the type of the log
37 * - levels to specify the detail-level of the log
39 * Use combinations of these to build detailed loglevels, such
40 * as CONTROL|LEVEL2 fore a detailed cotrol level, or
41 * use RAW to see all raw data dumps (except private).
55 * Logs important for the sysadmin.
68 * Log most important output, can be omitted.
72 * Log more detailed output.
76 * Log even more detailed output.
80 * Use maximum detailed output.
82 LEVEL3
= LEVEL2
+ 128,
85 * Summary for all types with all detail-levels.
87 FULL
= LEVEL3
+ CONTROL
+ ERROR
+ RAW
+ PRIVATE
+ AUDIT
90 typedef struct logger_t logger_t
;
93 * @brief Class to simplify logging.
103 * @brief Log an entry, using printf()-like params.
105 * All specified loglevels must be activated that
108 * @param this logger_t object
109 * @param loglevel or'ed set of log_level_t's
110 * @param format printf like format string
111 * @param ... printf like parameters
113 void (*log
) (logger_t
*this, log_level_t log_level
, const char *format
, ...);
116 * @brief Log some bytes, useful for debugging.
118 * All specified loglevels must be activated that
121 * @param this logger_t object
122 * @param loglevel or'ed set of log_level_t's
123 * @param label a labeling name, logged with the bytes
124 * @param bytes pointer to the bytes to dump
125 * @param len number of bytes to dump
127 void (*log_bytes
) (logger_t
*this, log_level_t loglevel
, const char *label
, const char *bytes
, size_t len
);
130 * @brief Log a chunk, useful for debugging.
132 * All specified loglevels must be activated that
135 * @param this logger_t object
136 * @param loglevel or'ed set of log_level_t's
137 * @param label a labeling name, logged with the bytes
138 * @param chunk chunk to log
140 void (*log_chunk
) (logger_t
*this, log_level_t loglevel
, const char *label
, chunk_t chunk
);
143 * @brief Enables a loglevel for the current logger_t object.
145 * @param this logger_t object
146 * @param log_level loglevel to enable
148 void (*enable_level
) (logger_t
*this, log_level_t log_level
);
151 * @brief Disables a loglevel for the current logger_t object.
153 * @param this logger_t object
154 * @param log_level loglevel to enable
156 void (*disable_level
) (logger_t
*this, log_level_t log_level
);
159 * @brief Set the output of the logger.
161 * Use NULL for syslog.
163 * @param this logger_t object
164 * @param output file, where log output should be written
166 void (*set_output
) (logger_t
*this, FILE *output
);
169 * @brief Get the currently used loglevel.
171 * @param this logger_t object
172 * @return currently used loglevel
174 log_level_t (*get_level
) (logger_t
*this);
177 * @brief Destroys a logger_t object.
179 * @param this logger_t object
181 void (*destroy
) (logger_t
*this);
185 * @brief Constructor to create a logger_t object.
187 * @param logger_name name for the logger_t object
188 * @param log_level or'ed set of log_levels to assign to the new logger_t object
189 * @param log_thread_id TRUE if thread id should also be logged
190 * @param output FILE * if log has to go on a file output, NULL for syslog
191 * @return logger_t object
195 logger_t
*logger_create(char *logger_name
, log_level_t log_level
, bool log_thread_id
, FILE * output
);