X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilclog.c;h=b415c664d1eecc3ed45b0b6829da2895f859c206;hb=a818c5b5411bbc4436d1c5f011236985c96bb787;hp=cf89958b1bfc783718d0185ad3a4f51f67bc6b96;hpb=d8414257c2a60e775002e7550feeaa63c17e6f62;p=silc.git diff --git a/lib/silcutil/silclog.c b/lib/silcutil/silclog.c index cf89958b..b415c664 100644 --- a/lib/silcutil/silclog.c +++ b/lib/silcutil/silclog.c @@ -32,7 +32,7 @@ struct SilcLogStruct { char *filename; FILE *fp; - uint32 maxsize; + SilcUInt32 maxsize; char *typename; SilcLogType type; SilcLogCb cb; @@ -43,8 +43,8 @@ typedef struct SilcLogStruct *SilcLog; /* These are the known logging channels */ static struct SilcLogStruct silclogs[SILC_LOG_MAX] = { {NULL, NULL, 0, "Info", SILC_LOG_INFO, NULL, NULL}, - {NULL, NULL, 0, "Error", SILC_LOG_ERROR, NULL, NULL}, {NULL, NULL, 0, "Warning", SILC_LOG_WARNING, NULL, NULL}, + {NULL, NULL, 0, "Error", SILC_LOG_ERROR, NULL, NULL}, {NULL, NULL, 0, "Fatal", SILC_LOG_FATAL, NULL, NULL}, }; @@ -59,7 +59,7 @@ bool silc_debug_hexdump = FALSE; long silc_log_flushdelay = 300; /* Regular pattern matching expression for the debug output */ -static char *silc_log_debug_string = NULL; +char *silc_log_debug_string = NULL; /* Debug callbacks. If set these are used instead of default ones. */ static SilcLogDebugCb silc_log_debug_cb = NULL; @@ -241,7 +241,7 @@ char *silc_log_get_file(SilcLogType type) } /* Set and initialize the specified logging channel. See the API reference */ -bool silc_log_set_file(SilcLogType type, char *filename, uint32 maxsize, +bool silc_log_set_file(SilcLogType type, char *filename, SilcUInt32 maxsize, SilcSchedule scheduler) { FILE *fp = NULL; @@ -344,18 +344,22 @@ void silc_log_output_debug(char *file, char *function, { if (!silc_debug) goto end; + if (silc_log_debug_string && - !silc_string_regex_match(silc_log_debug_string, file) && - !silc_string_regex_match(silc_log_debug_string, function)) + !silc_string_regex_match(silc_log_debug_string, file) && + !silc_string_regex_match(silc_log_debug_string, function)) goto end; + if (silc_log_debug_cb) { if ((*silc_log_debug_cb)(file, function, line, string, silc_log_debug_context)) goto end; } + fprintf(stderr, "%s:%d: %s\n", function, line, string); fflush(stderr); -end: + + end: silc_free(string); } @@ -363,7 +367,7 @@ end: void silc_log_output_hexdump(char *file, char *function, int line, void *data_in, - uint32 len, char *string) + SilcUInt32 len, char *string) { int i, k; int off, pos, count; @@ -371,10 +375,12 @@ void silc_log_output_hexdump(char *file, char *function, if (!silc_debug_hexdump) goto end; + if (silc_log_debug_string && - !silc_string_regex_match(silc_log_debug_string, file) && - !silc_string_regex_match(silc_log_debug_string, function)) + !silc_string_regex_match(silc_log_debug_string, file) && + !silc_string_regex_match(silc_log_debug_string, function)) goto end; + if (silc_log_hexdump_cb) { if ((*silc_log_hexdump_cb)(file, function, line, data_in, len, string, silc_log_hexdump_context)) @@ -382,7 +388,6 @@ void silc_log_output_hexdump(char *file, char *function, } fprintf(stderr, "%s:%d: %s\n", function, line, string); - silc_free(string); k = 0; pos = 0; @@ -438,9 +443,8 @@ void silc_log_output_hexdump(char *file, char *function, if (count < 16) break; } - return; -end: + end: silc_free(string); }