1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

/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
This commit is contained in:
Timo Sirainen 2000-06-04 12:59:46 +00:00 committed by cras
parent 8562737548
commit 086e433bc6
2 changed files with 29 additions and 17 deletions

View File

@ -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) {
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);
log = NULL;
}
}
if (log != NULL) {
if (stristr(args, "-autoopen"))
log->autoopen = TRUE;
log->rotate = rotate;
log_update(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" : "");

View File

@ -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 },