5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 1997 - 2000 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
24 /* Set TRUE/FALSE to enable/disable debugging */
25 extern bool silc_debug;
26 extern bool silc_debug_hexdump;
27 extern char *silc_debug_string;
37 /* Log type name structure. */
43 /* Log function callback. */
44 typedef void (*SilcLogCb)(char *message);
46 /* Debug function callback. */
47 typedef void (*SilcDebugCb)(char *file, char *function,
48 int line, char *message);
50 /* Debug hexdump function callback. */
51 typedef void (*SilcDebugHexdumpCb)(char *file, char *function,
52 int line, unsigned char *data,
53 uint32 data_len, char *message);
55 /* Default log filenames */
56 #define SILC_LOG_FILE_INFO "silcd.log"
57 #define SILC_LOG_FILE_WARNING "silcd_error.log"
58 #define SILC_LOG_FILE_ERROR SILC_LOG_FILE_WARNING
59 #define SILC_LOG_FILE_FATAL SILC_LOG_FILE_WARNING
61 /* Log files. Set by silc_log_set_logfiles. */
62 extern char *log_info_file;
63 extern char *log_warning_file;
64 extern char *log_error_file;
65 extern char *log_fatal_file;
66 extern uint32 log_info_size;
67 extern uint32 log_warning_size;
68 extern uint32 log_error_size;
69 extern uint32 log_fatal_size;
72 #define __FUNCTION__ ""
76 #define SILC_LOG_INFO(fmt) (silc_log_output(log_info_file, \
80 #define SILC_LOG_WARNING(fmt) (silc_log_output(log_warning_file, \
84 #define SILC_LOG_ERROR(fmt) (silc_log_output(log_error_file, \
88 #define SILC_LOG_FATAL(fmt) (silc_log_output(log_fatal_file, \
93 /* Debug macro is a bit different from other logging macros and it
94 is compiled in only if debugging is enabled. */
96 #define SILC_LOG_DEBUG(fmt) (silc_log_output_debug(__FILE__, \
100 #define SILC_LOG_HEXDUMP(fmt, data, len) \
101 (silc_log_output_hexdump(__FILE__, \
107 #define SILC_LOG_DEBUG(fmt)
108 #define SILC_LOG_HEXDUMP(fmt, data, len)
112 void silc_log_output_debug(char *file, char *function,
113 int line, char *string);
114 void silc_log_output(const char *filename, uint32 maxsize,
115 SilcLogType type, char *string);
116 void silc_log_output_hexdump(char *file, char *function,
117 int line, void *data_in,
118 uint32 len, char *string);
119 void silc_log_set_files(char *info, uint32 info_size,
120 char *warning, uint32 warning_size,
121 char *error, uint32 error_size,
122 char *fatal, uint32 fatal_size);
123 void silc_log_set_callbacks(SilcLogCb info, SilcLogCb warning,
124 SilcLogCb error, SilcLogCb fatal);
125 void silc_log_reset_callbacks();
126 void silc_log_set_debug_callbacks(SilcDebugCb debug,
127 SilcDebugHexdumpCb debug_hexdump);
128 void silc_log_reset_debug_callbacks();
129 void silc_log_set_debug_string(const char *debug_string);