X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilclog.c;h=f75a735adb955c424c5b2adaf39d27070a3fd01d;hb=a822fca4344037f17da731b4cebb2c0d4a67ba60;hp=15c64884fec45277afd572fdf4fc32909f6f6070;hpb=6531fe2150971068f734791bea19419f679e6d33;p=silc.git diff --git a/lib/silcutil/silclog.c b/lib/silcutil/silclog.c index 15c64884..f75a735a 100644 --- a/lib/silcutil/silclog.c +++ b/lib/silcutil/silclog.c @@ -23,6 +23,7 @@ /* Set TRUE/FALSE to enable/disable debugging */ int silc_debug = FALSE; +char *silc_debug_string = NULL; /* SILC Log name strings. These strings are printed to the log file. */ const SilcLogTypeName silc_log_types[] = @@ -148,6 +149,13 @@ void silc_log_output_debug(char *file, char *function, return; } + if (silc_debug_string && + (!silc_string_regex_match(silc_debug_string, file) && + !silc_string_regex_match(silc_debug_string, function))) { + silc_free(string); + return; + } + if (debug_cb) { (*debug_cb)(file, function, line, string); @@ -175,6 +183,13 @@ void silc_log_output_hexdump(char *file, char *function, return; } + if (silc_debug_string && + (!silc_string_regex_match(silc_debug_string, file) && + !silc_string_regex_match(silc_debug_string, function))) { + silc_free(string); + return; + } + if (debug_hexdump_cb) { (*debug_hexdump_cb)(file, function, line, data_in, len, string); @@ -294,3 +309,15 @@ void silc_log_reset_debug_callbacks() debug_cb = NULL; debug_hexdump_cb = NULL; } + +/* Set current debug string */ + +void silc_log_set_debug_string(const char *debug_string) +{ + silc_free(silc_debug_string); + if (strchr(debug_string, '(') && + strchr(debug_string, ')')) + silc_debug_string = strdup(debug_string); + else + silc_debug_string = silc_string_regexify(debug_string); +}