aboutsummaryrefslogtreecommitdiff
path: root/src/util/common_logging.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/common_logging.c')
-rw-r--r--src/util/common_logging.c52
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 */
124static unsigned int skip_log; 124static unsigned int skip_log;
125 125
126/**
127 * File descriptor to use for "stderr", or NULL for none.
128 */
126static FILE *GNUNET_stderr; 129static 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 */
133static enum GNUNET_ErrorType 138static enum GNUNET_ErrorType
134get_type (const char *log) 139get_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 */
222static void 237static void
223output_message (enum GNUNET_ErrorType kind, 238output_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 */
238static void 259static void
239flush_bulk (const char *datestr) 260flush_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 */
297static void 326static void
298mylog (enum GNUNET_ErrorType kind, 327mylog (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 */
349void 385void
350GNUNET_log (enum GNUNET_ErrorType kind, const char *message, ...) 386GNUNET_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 */
359void 404void
360GNUNET_log_from (enum GNUNET_ErrorType kind, 405GNUNET_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 */
373const char * 421const char *
374GNUNET_error_type_to_string (enum GNUNET_ErrorType kind) 422GNUNET_error_type_to_string (enum GNUNET_ErrorType kind)