diff options
Diffstat (limited to 'src/util/common_logging.c')
-rw-r--r-- | src/util/common_logging.c | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 436e009ab..ea3ab4f78 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c | |||
@@ -123,12 +123,17 @@ static struct CustomLogger *loggers; | |||
123 | */ | 123 | */ |
124 | static unsigned int skip_log; | 124 | static unsigned int skip_log; |
125 | 125 | ||
126 | /** | ||
127 | * File descriptor to use for "stderr", or NULL for none. | ||
128 | */ | ||
126 | static FILE *GNUNET_stderr; | 129 | static FILE *GNUNET_stderr; |
127 | 130 | ||
128 | /** | 131 | /** |
129 | * Convert a textual description of a loglevel | 132 | * Convert a textual description of a loglevel |
130 | * to the respective GNUNET_GE_KIND. | 133 | * to the respective GNUNET_GE_KIND. |
131 | * @returns GNUNET_GE_INVALID if log does not parse | 134 | * |
135 | * @param log loglevel to parse | ||
136 | * @return GNUNET_GE_INVALID if log does not parse | ||
132 | */ | 137 | */ |
133 | static enum GNUNET_ErrorType | 138 | static enum GNUNET_ErrorType |
134 | get_type (const char *log) | 139 | get_type (const char *log) |
@@ -144,6 +149,7 @@ get_type (const char *log) | |||
144 | return GNUNET_ERROR_TYPE_INVALID; | 149 | return GNUNET_ERROR_TYPE_INVALID; |
145 | } | 150 | } |
146 | 151 | ||
152 | |||
147 | /** | 153 | /** |
148 | * Setup logging. | 154 | * Setup logging. |
149 | * | 155 | * |
@@ -219,6 +225,15 @@ GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls) | |||
219 | GNUNET_free (pos); | 225 | GNUNET_free (pos); |
220 | } | 226 | } |
221 | 227 | ||
228 | |||
229 | /** | ||
230 | * Actually output the log message. | ||
231 | * | ||
232 | * @param kind how severe was the issue | ||
233 | * @param comp component responsible | ||
234 | * @param datestr current date/time | ||
235 | * @param msg the actual message | ||
236 | */ | ||
222 | static void | 237 | static void |
223 | output_message (enum GNUNET_ErrorType kind, | 238 | output_message (enum GNUNET_ErrorType kind, |
224 | const char *comp, const char *datestr, const char *msg) | 239 | const char *comp, const char *datestr, const char *msg) |
@@ -235,6 +250,12 @@ output_message (enum GNUNET_ErrorType kind, | |||
235 | } | 250 | } |
236 | } | 251 | } |
237 | 252 | ||
253 | |||
254 | /** | ||
255 | * Flush an existing bulk report to the output. | ||
256 | * | ||
257 | * @param datastr our current timestamp | ||
258 | */ | ||
238 | static void | 259 | static void |
239 | flush_bulk (const char *datestr) | 260 | flush_bulk (const char *datestr) |
240 | { | 261 | { |
@@ -294,6 +315,14 @@ GNUNET_log_skip (unsigned int n, int check_reset) | |||
294 | } | 315 | } |
295 | 316 | ||
296 | 317 | ||
318 | /** | ||
319 | * Output a log message using the default mechanism. | ||
320 | * | ||
321 | * @param kind how severe was the issue | ||
322 | * @param comp component responsible | ||
323 | * @param message the actual message | ||
324 | * @param va arguments to the format string "message" | ||
325 | */ | ||
297 | static void | 326 | static void |
298 | mylog (enum GNUNET_ErrorType kind, | 327 | mylog (enum GNUNET_ErrorType kind, |
299 | const char *comp, const char *message, va_list va) | 328 | const char *comp, const char *message, va_list va) |
@@ -346,6 +375,13 @@ mylog (enum GNUNET_ErrorType kind, | |||
346 | } | 375 | } |
347 | 376 | ||
348 | 377 | ||
378 | /** | ||
379 | * Main log function. | ||
380 | * | ||
381 | * @param kind how serious is the error? | ||
382 | * @param message what is the message (format string) | ||
383 | * @param ... arguments for format string | ||
384 | */ | ||
349 | void | 385 | void |
350 | GNUNET_log (enum GNUNET_ErrorType kind, const char *message, ...) | 386 | GNUNET_log (enum GNUNET_ErrorType kind, const char *message, ...) |
351 | { | 387 | { |
@@ -356,6 +392,15 @@ GNUNET_log (enum GNUNET_ErrorType kind, const char *message, ...) | |||
356 | } | 392 | } |
357 | 393 | ||
358 | 394 | ||
395 | /** | ||
396 | * Log function that specifies an alternative component. | ||
397 | * This function should be used by plugins. | ||
398 | * | ||
399 | * @param kind how serious is the error? | ||
400 | * @param comp component responsible for generating the message | ||
401 | * @param message what is the message (format string) | ||
402 | * @param ... arguments for format string | ||
403 | */ | ||
359 | void | 404 | void |
360 | GNUNET_log_from (enum GNUNET_ErrorType kind, | 405 | GNUNET_log_from (enum GNUNET_ErrorType kind, |
361 | const char *comp, const char *message, ...) | 406 | const char *comp, const char *message, ...) |
@@ -368,7 +413,10 @@ GNUNET_log_from (enum GNUNET_ErrorType kind, | |||
368 | 413 | ||
369 | 414 | ||
370 | /** | 415 | /** |
371 | * Convert KIND to String | 416 | * Convert error type to string. |
417 | * | ||
418 | * @param kind type to convert | ||
419 | * @return string corresponding to the type | ||
372 | */ | 420 | */ |
373 | const char * | 421 | const char * |
374 | GNUNET_error_type_to_string (enum GNUNET_ErrorType kind) | 422 | GNUNET_error_type_to_string (enum GNUNET_ErrorType kind) |