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;
26 extern char *silc_debug_string;
36 /* Log type name structure. */
42 /* Log function callback. */
43 typedef void (*SilcLogCb)(char *message);
45 /* Debug function callback. */
46 typedef void (*SilcDebugCb)(char *file, char *function,
47 int line, char *message);
49 /* Debug hexdump function callback. */
50 typedef void (*SilcDebugHexdumpCb)(char *file, char *function,
51 int line, unsigned char *data,
52 uint32 data_len, char *message);
54 /* Default log filenames */
55 #define SILC_LOG_FILE_INFO "silcd.log"
56 #define SILC_LOG_FILE_WARNING "silcd_error.log"
57 #define SILC_LOG_FILE_ERROR SILC_LOG_FILE_WARNING
58 #define SILC_LOG_FILE_FATAL SILC_LOG_FILE_WARNING
60 /* Log files. Set by silc_log_set_logfiles. */
61 extern char *log_info_file;
62 extern char *log_warning_file;
63 extern char *log_error_file;
64 extern char *log_fatal_file;
65 extern uint32 log_info_size;
66 extern uint32 log_warning_size;
67 extern uint32 log_error_size;
68 extern uint32 log_fatal_size;
71 #define __FUNCTION__ ""
75 #define SILC_LOG_INFO(fmt) (silc_log_output(log_info_file, \
79 #define SILC_LOG_WARNING(fmt) (silc_log_output(log_warning_file, \
83 #define SILC_LOG_ERROR(fmt) (silc_log_output(log_error_file, \
87 #define SILC_LOG_FATAL(fmt) (silc_log_output(log_fatal_file, \
92 /* Debug macro is a bit different from other logging macros and it
93 is compiled in only if debugging is enabled. */
95 #define SILC_LOG_DEBUG(fmt) (silc_log_output_debug(__FILE__, \
99 #define SILC_LOG_HEXDUMP(fmt, data, len) \
100 (silc_log_output_hexdump(__FILE__, \
106 #define SILC_LOG_DEBUG(fmt)
107 #define SILC_LOG_HEXDUMP(fmt, data, len)
111 void silc_log_output_debug(char *file, char *function,
112 int line, char *string);
113 void silc_log_output(const char *filename, uint32 maxsize,
114 SilcLogType type, char *string);
115 void silc_log_output_hexdump(char *file, char *function,
116 int line, void *data_in,
117 uint32 len, char *string);
118 void silc_log_set_files(char *info, uint32 info_size,
119 char *warning, uint32 warning_size,
120 char *error, uint32 error_size,
121 char *fatal, uint32 fatal_size);
122 void silc_log_set_callbacks(SilcLogCb info, SilcLogCb warning,
123 SilcLogCb error, SilcLogCb fatal);
124 void silc_log_reset_callbacks();
125 void silc_log_set_debug_callbacks(SilcDebugCb debug,
126 SilcDebugHexdumpCb debug_hexdump);
127 void silc_log_reset_debug_callbacks();
128 void silc_log_set_debug_string(const char *debug_string);