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 unsigned int 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 unsigned int log_info_size;
65 extern unsigned int log_warning_size;
66 extern unsigned int log_error_size;
67 extern unsigned int log_fatal_size;
70 #define SILC_LOG_INFO(fmt) (silc_log_output(log_info_file, \
74 #define SILC_LOG_WARNING(fmt) (silc_log_output(log_warning_file, \
78 #define SILC_LOG_ERROR(fmt) (silc_log_output(log_error_file, \
82 #define SILC_LOG_FATAL(fmt) (silc_log_output(log_fatal_file, \
87 /* Debug macro is a bit different from other logging macros and it
88 is compiled in only if debugging is enabled. */
90 #define SILC_LOG_DEBUG(fmt) (silc_log_output_debug(__FILE__, \
94 #define SILC_LOG_HEXDUMP(fmt, data, len) \
95 (silc_log_output_hexdump(__FILE__, \
101 #define SILC_LOG_DEBUG(fmt)
102 #define SILC_LOG_HEXDUMP(fmt, data, len)
106 void silc_log_output_debug(char *file, char *function,
107 int line, char *string);
108 void silc_log_output(const char *filename, unsigned int maxsize,
109 SilcLogType type, char *string);
110 void silc_log_output_hexdump(char *file, char *function,
111 int line, void *data_in,
112 unsigned int len, char *string);
113 void silc_log_set_files(char *info, unsigned int info_size,
114 char *warning, unsigned int warning_size,
115 char *error, unsigned int error_size,
116 char *fatal, unsigned int fatal_size);
117 void silc_log_set_callbacks(SilcLogCb info, SilcLogCb warning,
118 SilcLogCb error, SilcLogCb fatal);
119 void silc_log_reset_callbacks();
120 void silc_log_set_debug_callbacks(SilcDebugCb debug,
121 SilcDebugHexdumpCb debug_hexdump);
122 void silc_log_reset_debug_callbacks();