diff options
author | Timo Sirainen <cras@irssi.org> | 2000-06-04 12:59:46 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-06-04 12:59:46 +0000 |
commit | 086e433bc605ee21ed8d084ea1697fd767b3c946 (patch) | |
tree | 73090978ffb228270bf6ae2198c04ca28d6d78d8 /src/fe-common/core | |
parent | 856273754804e6959f086ac75932ffa77eb39a8a (diff) | |
download | irssi-086e433bc605ee21ed8d084ea1697fd767b3c946.zip |
/LOG show reference number for each log, you can use it with /LOG START,
STOP and CLOSE commands instead of file name.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@288 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/core')
-rw-r--r-- | src/fe-common/core/fe-log.c | 44 | ||||
-rw-r--r-- | src/fe-common/core/module-formats.c | 2 |
2 files changed, 29 insertions, 17 deletions
diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c index 116821c3..17af0cf3 100644 --- a/src/fe-common/core/fe-log.c +++ b/src/fe-common/core/fe-log.c @@ -71,32 +71,43 @@ static void cmd_log_open(const char *data) } log = log_create_rec(fname, level, targetarg); - if (log != NULL && log->handle == -1 && stristr(args, "-noopen") == NULL) { - /* start logging */ - if (log_start_logging(log)) { - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, - IRCTXT_LOG_OPENED, fname); - } else { - log_close(log); - log = NULL; - } - } - if (log != NULL) { if (stristr(args, "-autoopen")) log->autoopen = TRUE; log->rotate = rotate; log_update(log); + + if (log->handle == -1 && stristr(args, "-noopen") == NULL) { + /* start logging */ + if (log_start_logging(log)) { + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + IRCTXT_LOG_OPENED, fname); + } else { + log_close(log); + } + } } g_free(params); } +static LOG_REC *log_find_from_data(const char *data) +{ + GSList *tmp; + + if (!is_numeric(data, ' ')) + return log_find(data); + + /* with index number */ + tmp = g_slist_nth(logs, atoi(data)-1); + return tmp == NULL ? NULL : tmp->data; +} + static void cmd_log_close(const char *data) { LOG_REC *log; - log = log_find(data); + log = log_find_from_data(data); if (log == NULL) printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, IRCTXT_LOG_NOT_OPEN, data); else { @@ -109,7 +120,7 @@ static void cmd_log_start(const char *data) { LOG_REC *log; - log = log_find(data); + log = log_find_from_data(data); if (log != NULL) { log_start_logging(log); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_LOG_OPENED, data); @@ -120,7 +131,7 @@ static void cmd_log_stop(const char *data) { LOG_REC *log; - log = log_find(data); + log = log_find_from_data(data); if (log == NULL || log->handle == -1) printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, IRCTXT_LOG_NOT_OPEN, data); else { @@ -133,9 +144,10 @@ static void cmd_log_list(void) { GSList *tmp; char *levelstr, *items, *rotate; + int index; printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_LOG_LIST_HEADER); - for (tmp = logs; tmp != NULL; tmp = tmp->next) { + for (tmp = logs, index = 1; tmp != NULL; tmp = tmp->next, index++) { LOG_REC *rec = tmp->data; levelstr = bits2level(rec->level); @@ -145,7 +157,7 @@ static void cmd_log_list(void) g_strdup_printf(" -rotate %s", log_rotate2str(rec->rotate)); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_LOG_LIST, - rec->fname, items != NULL ? items : "", + index, rec->fname, items != NULL ? items : "", levelstr, rotate != NULL ? rotate : "", rec->autoopen ? " -autoopen" : ""); diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index 2371db45..83e425eb 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -79,7 +79,7 @@ FORMAT_REC fecommon_core_formats[] = { { "log_started", "Started logging to file %W$0", 1, { 0 } }, { "log_stopped", "Stopped logging to file %W$0", 1, { 0 } }, { "log_list_header", "Logs:", 0 }, - { "log_list", "$0: $1 $2$3$4", 5, { 0, 0, 0, 0, 0 } }, + { "log_list", "$0 $1: $2 $3$4$5", 6, { 1, 0, 0, 0, 0, 0 } }, { "log_list_footer", "", 0 }, { "windowlog_file", "Window LOGFILE set to $0", 1, { 0 } }, { "windowlog_file_logging", "Can't change window's logfile while log is on", 0 }, |