silclog.h
- Author: Johnny Mnemonic <johnny@themnemonic.org>
+ Author: Giovanni Giacobbi <giovanni@giacobbi.net>
Copyright (C) 1997 - 2002 Pekka Riikonen
*/
-/****h* silcutil/SilcLogAPI
+/****h* silcutil/SILC Logging Interface
*
* DESCRIPTION
*
* This is the main logging channel id. There are currently four known
* logging channels (plus the debugging output channel), and they are
* ordered by importance.
+ *
* See the source code for SILC coding conventions about how to choose
* the right output channel.
*
/* This should be used for warnings and non critical failures */
SILC_LOG_WARNING,
- /* Generic error and critical failures messages */
+ /* Generic error and critical failure messages */
SILC_LOG_ERROR,
/* Fatal messages (usually situations that will lead to a program crash */
* SYNOPSIS
*
* typedef bool (*SilcDebugHexdumpCb)(char *file, char *function, int line,
- * unsigned char *data, uint32 data_len,
+ * unsigned char *data, SilcUInt32 data_len,
* char *message, void *context;
*
* DESCRIPTION
*
***/
typedef bool (*SilcLogHexdumpCb)(char *file, char *function, int line,
- unsigned char *data, uint32 data_len,
+ 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
/* Macros */
-#ifdef WIN32
+#if defined(WIN32)
+#ifndef __FUNCTION__
#define __FUNCTION__ ""
#endif
+#endif
+
+/****d* silcutil/SilcLogAPI/SILC_ENABLE_DEBUG
+ *
+ * NAME
+ *
+ * #define SILC_ENABLE_DEBUG
+ *
+ * DESCRIPTION
+ *
+ * Use this macro to enable the debugging in your application. If
+ * SILC was compiled with debugging enabled, this macro enables it.
+ * Use this macro in your application's main header, or in place where
+ * you need to enable the debugging.
+ *
+ * NOTES
+ *
+ * You still can control the debugging with silc_debug variable, on
+ * whether to actually print the debugging or not. This macro is
+ * used to enable debugging, not to say it is printed or not.
+ *
+ * SOURCE
+ */
+#define SILC_ENABLE_DEBUG \
+ #ifndef SILC_DEBUG \
+ #define SILC_DEBUG 1 \
+ #endif
+/***/
/****d* silcutil/SilcLogAPI/SILC_LOG_INFO
*
*
* SOURCE
*/
-#ifdef SILC_DEBUG
+#if defined(SILC_DEBUG)
#define SILC_LOG_DEBUG(fmt) silc_log_output_debug(__FILE__, \
__FUNCTION__, \
__LINE__, \
silc_format fmt)
+#define SILC_NOT_IMPLEMENTED(string) \
+ SILC_LOG_INFO(("*********** %s: NOT IMPLEMENTED YET", string));
#else
#define SILC_LOG_DEBUG(fmt)
+#define SILC_NOT_IMPLEMENTED(string)
#endif /* SILC_DEBUG */
/***/
*
* SOURCE
*/
-#ifdef SILC_DEBUG
+#if defined(SILC_DEBUG)
#define SILC_LOG_HEXDUMP(fmt, data, len) silc_log_output_hexdump(__FILE__, \
__FUNCTION__, \
__LINE__, \
*
* This is the main function for logging output. Please note that you
* should rather use one of the logging wrapper macros.
+ *
* If you really want to use this function, its usage is quite simple.
* The `type' parameter identifies the channel to use, while the `string'
* parameter must be a dynamic allocated (null-terminated) buffer, because
* If there has been an error during the opening of this channel, NULL
* is returned, even if the file has been previously set with
* silc_log_set_file().
+ *
* The returned pointer points to internally allocated storage and must
* not be freed, modified or stored.
*
*
* SYNOPSIS
*
- * bool silc_log_set_file(SilcLogType type, char *filename, uint32 maxsize,
+ * bool silc_log_set_file(SilcLogType type, char *filename,
+ * SilcUInt32 maxsize,
* SilcSchedule scheduler);
*
* DESCRIPTION
* logging file for the channel `type'. If you specify an illegal filename
* a warning message is printed and FALSE is returned. In this case
* logging settings are not changed.
+ *
* You can disable logging for a channel by specifying NULL filename, the
- * maxsize in this case is not important.
- * The `scheduler' parameter is needed by the internal logging to allow
- * buffered output and thus to save HD activity.
+ * maxsize in this case is not important. The `scheduler' parameter is
+ * needed by the internal logging to allow buffered output and thus to
+ * save HD activity.
*
***/
-bool silc_log_set_file(SilcLogType type, char *filename, uint32 maxsize,
+bool silc_log_set_file(SilcLogType type, char *filename, SilcUInt32 maxsize,
SilcSchedule scheduler);
/****f* silcutil/SilcLogAPI/silc_log_set_callback
* trigger the callback function. If the callback function returns TRUE
* SilcLog will assume the input as handled and won't run its default
* handler.
+ *
* You can disable/remove a callback by setting it to NULL or calling the
- * function silc_log_reset_callbacks.
- * If set, the callback function must be in the form described by
- * SilcLogCb.
+ * function silc_log_reset_callbacks. If set, the callback function
+ * must be in the form described by SilcLogCb.
*
* SEE ALSO
* silc_log_reset_callbacks
*
* Forces all logging channels to close and reopen their streams. Useful
* for example after a SIGHUP signal.
- * Please note that this function could cause some warning messages if
- * some logging channel points to an illegal filename.
+ * Please note that this function could generate some warning messages if
+ * one or more logging channels point to an illegal filename.
*
***/
void silc_log_reset_all();
*
* void silc_log_output_hexdump(char *file, char *function,
* int line, void *data_in,
- * uint32 len, char *string);
+ * SilcUInt32 len, char *string);
*
* DESCRIPTION
*
***/
void silc_log_output_hexdump(char *file, char *function,
int line, void *data_in,
- uint32 len, char *string);
+ SilcUInt32 len, char *string);
/****f* silcutil/SilcLogAPI/silc_log_set_debug_callbacks
*