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
31 typedef enum logger_level_t logger_level_t
;
34 * @brief Log Levels supported by the logger object.
36 * Logleves are devided in two types:
37 * - One to specify the type log
38 * - One to specify the detail-level of the log
40 * Use combinations of these to build detailed loglevels, such
41 * as CONTROL|MORE fore a detailed cotrol level, or
42 * use RAW to see all raw data dumps (except private).
65 * Use more detailed output for those above.
69 * Use even more detailed output.
73 * Use full detailed output.
78 * Summary for all types with all detail-levels.
80 FULL
= ALL
+ CONTROL
+ ERROR
+ RAW
+ PRIVATE
83 typedef struct logger_t logger_t
;
86 * @brief Class to simplify logging.
93 * @brief Log an entry, using printf()-like params.
95 * The specefied loglevels must ALL be activated that
98 * @param this logger_t object
99 * @param loglevel or'ed set of loglevels
100 * @param format printf like format string
101 * @param ... printf like parameters
102 * @return SUCCESS in any case
104 status_t (*log
) (logger_t
*this, logger_level_t log_level
, char *format
, ...);
107 * @brief Log some bytes, useful for debugging.
109 * The specefied loglevels must ALL be activated that
112 * @param this logger_t object
113 * @param loglevel or'ed set of loglevels
114 * @param label a labeling name, logged with the bytes
115 * @param bytes pointer to the bytes to dump
116 * @param len number of bytes to dump
117 * @return SUCCESS in any case
119 status_t (*log_bytes
) (logger_t
*this, logger_level_t loglevel
, char *label
, char *bytes
, size_t len
);
122 * @brief Log a chunk, useful for debugging.
124 * The specefied loglevels must ALL be activated that
127 * @param this logger_t object
128 * @param loglevel or'ed set of loglevels
129 * @param label a labeling name, logged with the bytes
130 * @param chunk pointer to a chunk to log
131 * @return SUCCESS in any case
133 status_t (*log_chunk
) (logger_t
*this, logger_level_t loglevel
, char *label
, chunk_t
*chunk
);
136 * @brief Enables a loglevel for the current logger_t object.
138 * @param this logger_t object
139 * @param log_level loglevel to enable
140 * @return SUCCESS in any case
142 status_t (*enable_level
) (logger_t
*this, logger_level_t log_level
);
145 * @brief Disables a loglevel for the current logger_t object.
147 * @param this logger_t object
148 * @param log_level loglevel to enable
149 * @return UCCESS in any case
151 status_t (*disable_level
) (logger_t
*this, logger_level_t log_level
);
154 * @brief Destroys a logger_t object.
156 * @param this logger_t object
157 * @return SUCCESS in any case
159 status_t (*destroy
) (logger_t
*this);
163 * @brief Constructor to create a logger_t object.
165 * @param logger_name name for the logger_t object
166 * @param log_level or'ed set of log_levels to assign to the new logger_t object
167 * @param log_pid TRUE if thread id should also be logged
168 * @param output FILE * if log has to go on a file output, NULL for syslog
171 * - NULL if out of ressources
175 logger_t
*logger_create(char *logger_name
, logger_level_t log_level
, bool log_pid
, FILE * output
);