diff --git a/src/core/log.c b/src/core/log.c index 75768601..18715832 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -246,18 +246,34 @@ void log_write_rec(LOG_REC *log, const char *str, int level) g_free_not_null(colorstr); } +static int itemcmp(const char *patt, const char *item) +{ + /* returns 0 on match, nonzero otherwise */ + + if (item == NULL) + return g_strcasecmp(patt, "*") != 0; + + for (;*patt != '\0'; patt++, item++) + { + if (*patt == '*') + return 0; + if (*patt != *item) + return 1; + } + return 0; +} + LOG_ITEM_REC *log_item_find(LOG_REC *log, int type, const char *item, const char *servertag) { GSList *tmp; g_return_val_if_fail(log != NULL, NULL); - g_return_val_if_fail(item != NULL, NULL); for (tmp = log->items; tmp != NULL; tmp = tmp->next) { LOG_ITEM_REC *rec = tmp->data; - if (rec->type == type && g_strcasecmp(rec->name, item) == 0 && + if (rec->type == type && itemcmp(rec->name, item) == 0 && (rec->servertag == NULL || (servertag != NULL && g_strcasecmp(rec->servertag, servertag) == 0))) return rec; diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c index 1b88364e..2d53c5fe 100644 --- a/src/fe-common/core/fe-log.c +++ b/src/fe-common/core/fe-log.c @@ -109,6 +109,8 @@ static void cmd_log_open(const char *data) targetarg = g_hash_table_lookup(optlist, "targets"); if (targetarg != NULL && *targetarg != '\0') log_add_targets(log, targetarg, servertag); + else if (servertag != NULL) + log_add_targets(log, "*", servertag); } if (g_hash_table_lookup(optlist, "autoopen")) @@ -189,17 +191,20 @@ static char *log_items_get_list(LOG_REC *log) GSList *tmp; GString *str; char *ret; + LOG_ITEM_REC *rec; g_return_val_if_fail(log != NULL, NULL); g_return_val_if_fail(log->items != NULL, NULL); str = g_string_new(NULL); for (tmp = log->items; tmp != NULL; tmp = tmp->next) { - LOG_ITEM_REC *rec = tmp->data; + rec = tmp->data; g_string_sprintfa(str, "%s, ", rec->name); } g_string_truncate(str, str->len-2); + if(rec->servertag != NULL) + g_string_sprintfa(str, " (%s)", rec->servertag); ret = str->str; g_string_free(str, FALSE);