X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilclog.h;h=624120356e8dbd9a35752e7559832ac19d199aa6;hb=c257b555225193e54d85daf541d29578b3c93882;hp=97d4d393b0c890e2626b5835fcc75bb15c800df4;hpb=303401f3d85675fbe2afcc27cdfe89ef2f0ca5c1;p=silc.git diff --git a/lib/silcutil/silclog.h b/lib/silcutil/silclog.h index 97d4d393..62412035 100644 --- a/lib/silcutil/silclog.h +++ b/lib/silcutil/silclog.h @@ -2,9 +2,9 @@ silclog.h - Author: Johnny Mnemonic + Author: Giovanni Giacobbi - Copyright (C) 1997 - 2002 Pekka Riikonen + Copyright (C) 1997 - 2005 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,6 +41,7 @@ * 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. * @@ -236,12 +237,39 @@ extern DLLAPI bool silc_debug_hexdump; /* Macros */ -#if defined(SILC_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 * * NAME @@ -351,8 +379,8 @@ extern DLLAPI bool silc_debug_hexdump; #define SILC_NOT_IMPLEMENTED(string) \ SILC_LOG_INFO(("*********** %s: NOT IMPLEMENTED YET", string)); #else -#define SILC_LOG_DEBUG(fmt) -#define SILC_NOT_IMPLEMENTED(string) +#define SILC_LOG_DEBUG(fmt) do { } while(0) +#define SILC_NOT_IMPLEMENTED(string) do { } while(0) #endif /* SILC_DEBUG */ /***/ @@ -385,12 +413,12 @@ extern DLLAPI bool silc_debug_hexdump; */ #if defined(SILC_DEBUG) #define SILC_LOG_HEXDUMP(fmt, data, len) silc_log_output_hexdump(__FILE__, \ - __FUNCTION__, \ - __LINE__, \ - (data), (len), \ + __FUNCTION__, \ + __LINE__, \ + (void *)(data), (len), \ silc_format fmt) #else -#define SILC_LOG_HEXDUMP(fmt, data, len) +#define SILC_LOG_HEXDUMP(fmt, data, len) do { } while(0) #endif /* SILC_DEBUG */ /***/ @@ -406,6 +434,7 @@ extern DLLAPI bool silc_debug_hexdump; * * 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 @@ -432,6 +461,7 @@ void silc_log_output(SilcLogType type, char *string); * 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. * @@ -442,7 +472,7 @@ char *silc_log_get_file(SilcLogType type); * * SYNOPSIS * - * bool silc_log_set_file(SilcLogType type, char *filename, + * bool silc_log_set_file(SilcLogType type, char *filename, * SilcUInt32 maxsize, * SilcSchedule scheduler); * @@ -452,10 +482,11 @@ char *silc_log_get_file(SilcLogType type); * 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, SilcUInt32 maxsize, @@ -475,10 +506,10 @@ bool silc_log_set_file(SilcLogType type, char *filename, SilcUInt32 maxsize, * 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 @@ -538,7 +569,7 @@ void silc_log_reset_all(); * * SYNOPSIS * - * void silc_log_output_debug(char *file, char *function, + * void silc_log_output_debug(char *file, const char *function, * int line, char *string); * * DESCRIPTION @@ -550,7 +581,7 @@ void silc_log_reset_all(); * dynamic allocated (null-terminated) buffer. * ***/ -void silc_log_output_debug(char *file, char *function, +void silc_log_output_debug(char *file, const char *function, int line, char *string); /****f* silcutil/SilcLogAPI/silc_log_output_hexdump @@ -571,7 +602,7 @@ void silc_log_output_debug(char *file, char *function, * `string' must be a dynamic allocated (null-terminated) buffer. * ***/ -void silc_log_output_hexdump(char *file, char *function, +void silc_log_output_hexdump(char *file, const char *function, int line, void *data_in, SilcUInt32 len, char *string);