-/* Log type name structure. */
-typedef struct {
- char *name;
- SilcLogType type;
-} SilcLogTypeName;
-
-/* Log function callback. */
-typedef void (*SilcLogCb)(char *message);
-
-/* Debug function callback. */
-typedef void (*SilcDebugCb)(char *file, char *function,
- int line, char *message);
-
-/* Debug hexdump function callback. */
-typedef void (*SilcDebugHexdumpCb)(char *file, char *function,
- int line, unsigned char *data,
- uint32 data_len, char *message);
-
-/* Default log filenames */
-#define SILC_LOG_FILE_INFO "silcd.log"
-#define SILC_LOG_FILE_WARNING "silcd_error.log"
-#define SILC_LOG_FILE_ERROR SILC_LOG_FILE_WARNING
-#define SILC_LOG_FILE_FATAL SILC_LOG_FILE_WARNING
-
-/* Log files. Set by silc_log_set_logfiles. */
-extern char *log_info_file;
-extern char *log_warning_file;
-extern char *log_error_file;
-extern char *log_fatal_file;
-extern uint32 log_info_size;
-extern uint32 log_warning_size;
-extern uint32 log_error_size;
-extern uint32 log_fatal_size;
-
-/* Log macros. */
-#define SILC_LOG_INFO(fmt) (silc_log_output(log_info_file, \
- log_info_size, \
- SILC_LOG_INFO, \
- silc_format fmt))
-#define SILC_LOG_WARNING(fmt) (silc_log_output(log_warning_file, \
- log_warning_size, \
- SILC_LOG_WARNING, \
- silc_format fmt))
-#define SILC_LOG_ERROR(fmt) (silc_log_output(log_error_file, \
- log_error_size, \
- SILC_LOG_ERROR, \
- silc_format fmt))
-#define SILC_LOG_FATAL(fmt) (silc_log_output(log_fatal_file, \
- log_fatal_size, \
- SILC_LOG_FATAL, \
- silc_format fmt))
-
-/* Debug macro is a bit different from other logging macros and it
- is compiled in only if debugging is enabled. */
-#ifdef SILC_DEBUG
-#define SILC_LOG_DEBUG(fmt) (silc_log_output_debug(__FILE__, \
- __FUNCTION__, \
- __LINE__, \
- silc_format fmt))
-#define SILC_LOG_HEXDUMP(fmt, data, len) \
- (silc_log_output_hexdump(__FILE__, \
- __FUNCTION__, \
- __LINE__, \
- (data), (len), \
- silc_format fmt))
-#else
-#define SILC_LOG_DEBUG(fmt)
-#define SILC_LOG_HEXDUMP(fmt, data, len)
+/****f* silcutil/SilcLogAPI/SilcLogCb
+ *
+ * SYNOPSIS
+ *
+ * typedef bool (*SilcLogCb)(SilcLogType type, char *message,
+ * void *context);
+ *
+ * DESCRIPTION
+ *
+ * The logging custom callback function. The `type' is the channel ID
+ * that triggered the event, which allows you to use the same callback
+ * function for multiple logging channels.
+ * The `message' parameter points to a null-terminated buffer containing
+ * the received message, while `context' is the caller-specified context.
+ * The message must not be modified or freed by the callback function.
+ *
+ * SEE ALSO
+ * silc_log_set_callback
+ *
+ ***/
+typedef bool (*SilcLogCb)(SilcLogType type, char *message, void *context);
+
+/****f* silcutil/SilcLogAPI/SilcLogDebugCb
+ *
+ * SYNOPSIS
+ *
+ * typedef bool (*SilcLogDebugCb)(char *file, char *function, int line,
+ * char *message, void *context);
+ *
+ * DESCRIPTION
+ *
+ * The debug logging callback function. The default behaviour is to
+ * output messages to stderr. `file', `function', and `line' are the
+ * corresponding offsets in the source files. `message' points to a
+ * null-terminated buffer containing the debugging message, and `context'
+ * is the caller-specified context.
+ * The message must not be modified or freed by the callback function.
+ * If the function returns TRUE, SilcLog will assume the message as handled
+ * and won't run its default handler.
+ *
+ * SEE ALSO
+ * silc_debug, silc_log_set_debug_callbacks
+ *
+ ***/
+typedef bool (*SilcLogDebugCb)(char *file, char *function, int line,
+ char *message, void *context);
+
+/****f* silcutil/SilcLogAPI/SilcLogHexdumpCb
+ *
+ * SYNOPSIS
+ *
+ * typedef bool (*SilcDebugHexdumpCb)(char *file, char *function, int line,
+ * unsigned char *data, SilcUInt32 data_len,
+ * char *message, void *context;
+ *
+ * DESCRIPTION
+ *
+ * The hexdump logging callback function. The default behaviour is to
+ * print a formatted hexdump to stderr, and is commonly what you would
+ * like it to be. `file', `function', and `line' are the corresponding
+ * offsets in the source files. `data' is the begin of the buffer that
+ * should be hexdumped, which is `data_len' bytes long.
+ * The `message' parameter points to a null-terminated buffer containing
+ * the received message, while `context' is the caller-specified context.
+ * The message must not be modified or freed by the callback function.
+ * If the function returns TRUE, SilcLog will assume the message as handled
+ * and won't run its default handler.
+ *
+ * SEE ALSO
+ * silc_debug_hexdump, silc_log_set_debug_callbacks
+ *
+ ***/
+typedef bool (*SilcLogHexdumpCb)(char *file, char *function, int line,
+ unsigned char *data, SilcUInt32 data_len,
+ char *message, void *context);
+
+/* Global Variables */
+
+/****v* silcutil/SilcLogAPI/silc_log_timestamp
+ *
+ * NAME
+ *
+ * bool silc_log_timestamp -- enable/disable fast logging timestamp
+ *
+ * DESCRIPTION
+ *
+ * Causes SilcLog to add a timestamp as returned by silc_get_time().
+ * This may be useful for example if you run your application under a
+ * daemon helper like watchdog that adds its own timestamp. Defaults to
+ * true.
+ *
+ ***/
+extern DLLAPI bool silc_log_timestamp;
+
+/****v* silcutil/SilcLogAPI/silc_log_quick
+ *
+ * NAME
+ *
+ * bool silc_log_quick -- enable/disable fast logging output
+ *
+ * DESCRIPTION
+ *
+ * SilcLog makes use of libc stream buffering output, which means that it
+ * saves HD activity by buffering the logging messages and writing them
+ * all together every some minutes (default is 5 minutes).
+ * Setting this variable to TRUE will force SilcLog to write messages to the
+ * filesystem as soon as they are received. This increases the CPU activity
+ * notably on bigger servers, but reduces memory usage.
+ * If you want to change the logging style on-the-fly, make sure to call
+ * silc_log_flush_all() after setting this variable to TRUE.
+ *
+ ***/
+extern DLLAPI bool silc_log_quick;
+
+/****v* silcutil/SilcLogAPI/silc_log_flushdelay
+ *
+ * NAME
+ *
+ * long silc_log_flushdelay -- flushing time delay
+ *
+ * DESCRIPTION
+ *
+ * Sets the logfiles flushing delay in seconds. As for now, changing this
+ * value AFTER logfiles initialization won't take effect until previous
+ * delay time will expire; for example if you change from 300 seconds to
+ * 60 seconds you will have to wait up to 300 seconds for this change to
+ * take effect.
+ * This value must be greater than 2 seconds.
+ *
+ ***/
+extern DLLAPI long silc_log_flushdelay;
+
+/****v* silcutil/SilcLogAPI/silc_debug
+ *
+ * NAME
+ *
+ * bool silc_debug -- enable/disable debugging output
+ *
+ * DESCRIPTION
+ *
+ * If silc_debug is set to FALSE, debugging functions won't procude any
+ * output. This is useful when for example you compile in the debugging
+ * support but at a certain point you want to send the program in the
+ * background.
+ *
+ * SEE ALSO
+ * SILC_LOG_DEBUG
+ *
+ ***/
+extern DLLAPI bool silc_debug;
+
+/****v* silcutil/SilcLogAPI/silc_debug_hexdump
+ *
+ * NAME
+ *
+ * bool silc_debug_hexdump -- enable/disable debugging output
+ *
+ * DESCRIPTION
+ *
+ * If silc_debug_hexdump is set to FALSE, debugging functions won't produce
+ * any output. This is useful when for example you compile in the debugging
+ * support but at a certain point you want to send the program in the
+ * background.
+ *
+ * SEE ALSO
+ * SILC_LOG_HEXDUMP
+ *
+ ***/
+extern DLLAPI bool silc_debug_hexdump;
+
+/* Macros */
+
+#if defined(WIN32)
+#ifndef __FUNCTION__
+#define __FUNCTION__ ""
+#endif