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 int silc_debug;
35 /* Log type name structure. */
41 /* Log function callback. */
42 typedef void (*SilcLogCb)(char *message);
44 /* Debug function callback. */
45 typedef void (*SilcDebugCb)(char *file, char *function,
46 int line, char *message);
48 /* Debug hexdump function callback. */
49 typedef void (*SilcDebugHexdumpCb)(char *file, char *function,
50 int line, unsigned char *data,
51 uint32 data_len, char *message);
53 /* Default log filenames */
54 #define SILC_LOG_FILE_INFO "silcd.log"
55 #define SILC_LOG_FILE_WARNING "silcd_error.log"
56 #define SILC_LOG_FILE_ERROR SILC_LOG_FILE_WARNING
57 #define SILC_LOG_FILE_FATAL SILC_LOG_FILE_WARNING
59 /* Log files. Set by silc_log_set_logfiles. */
60 extern char *log_info_file;
61 extern char *log_warning_file;
62 extern char *log_error_file;
63 extern char *log_fatal_file;
64 extern uint32 log_info_size;
65 extern uint32 log_warning_size;
66 extern uint32 log_error_size;
67 extern uint32 log_fatal_size;
70 #define __FUNCTION__ ""
74 #define SILC_LOG_INFO(fmt) (silc_log_output(log_info_file, \
78 #define SILC_LOG_WARNING(fmt) (silc_log_output(log_warning_file, \
82 #define SILC_LOG_ERROR(fmt) (silc_log_output(log_error_file, \
86 #define SILC_LOG_FATAL(fmt) (silc_log_output(log_fatal_file, \
91 /* Debug macro is a bit different from other logging macros and it
92 is compiled in only if debugging is enabled. */
94 #define SILC_LOG_DEBUG(fmt) (silc_log_output_debug(__FILE__, \
98 #define SILC_LOG_HEXDUMP(fmt, data, len) \
99 (silc_log_output_hexdump(__FILE__, \
105 #define SILC_LOG_DEBUG(fmt)
106 #define SILC_LOG_HEXDUMP(fmt, data, len)
110 void silc_log_output_debug(char *file, char *function,
111 int line, char *string);
112 void silc_log_output(const char *filename, uint32 maxsize,
113 SilcLogType type, char *string);
114 void silc_log_output_hexdump(char *file, char *function,
115 int line, void *data_in,
116 uint32 len, char *string);
117 void silc_log_set_files(char *info, uint32 info_size,
118 char *warning, uint32 warning_size,
119 char *error, uint32 error_size,
120 char *fatal, uint32 fatal_size);
121 void silc_log_set_callbacks(SilcLogCb info, SilcLogCb warning,
122 SilcLogCb error, SilcLogCb fatal);
123 void silc_log_reset_callbacks();
124 void silc_log_set_debug_callbacks(SilcDebugCb debug,
125 SilcDebugHexdumpCb debug_hexdump);
126 void silc_log_reset_debug_callbacks();