diff --git a/bip.conf.5 b/bip.conf.5 index 991eecc..a4a59a2 100644 --- a/bip.conf.5 +++ b/bip.conf.5 @@ -306,6 +306,11 @@ CAPAB (if you only use clients that support it for instance). \fBnetwork\fP The network name. See the \fBNETWORK SECTION\fP. +.TP +\fBlog\fP (override global log) +When \fBtrue\fP, the file logs are enabled for this connection. +When \fBfalse\fP, no log file is written, logs are kept in memory. + .TP \fBnick\fP BIP will send that string as your nickname upon connect. If not specified diff --git a/src/bip.c b/src/bip.c index 3afd062..a361847 100644 --- a/src/bip.c +++ b/src/bip.c @@ -567,6 +567,9 @@ static int add_connection(bip_t *bip, struct bipuser *user, list_t *data) list_add_last(&l->on_connect_send, t->pdata); t->pdata = NULL; break; + case LEX_LOG: + l->log->log_to_file = t->ndata; + break; #ifdef HAVE_LIBSSL case LEX_SSL_CHECK_MODE: if (strcmp(t->pdata, "basic") == 0) diff --git a/src/conf.y b/src/conf.y index 1a9a176..02b2823 100644 --- a/src/conf.y +++ b/src/conf.y @@ -188,6 +188,7 @@ con_command: LEX_NAME LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NAME, $3); } | LEX_NETWORK LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NETWORK, $3); } + | LEX_LOG LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_LOG, $3); } | LEX_NICK LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NICK, $3); } | LEX_USER LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_USER, $3); } | LEX_REALNAME LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_REALNAME, diff --git a/src/log.c b/src/log.c index ff1d5f1..3ae1d4e 100644 --- a/src/log.c +++ b/src/log.c @@ -264,7 +264,7 @@ static int log_add_file(log_t *logdata, const char *destination, char *canonical_fname = NULL; logfile_t *lf = NULL; - if (conf_log) { + if (logdata->log_to_file) { if (log_has_file(logdata, filename)) { canonical_fname = bip_strdup(filename); uniq_fname = filename_uniq(filename); @@ -309,7 +309,7 @@ static int log_add_file(log_t *logdata, const char *destination, hash_insert(&logdata->logfgs, destination, store); } - if (!conf_log && logdata->user->backlog) { + if (!logdata->log_to_file && logdata->user->backlog) { if (!store->memlog) store->memlog = list_new(NULL); } @@ -347,11 +347,11 @@ logstore_t *log_find_file(log_t *logdata, const char *destination) store = hash_get(&logdata->logfgs, destination); - if (store && !conf_log) + if (store && !logdata->log_to_file) return store; if (!store) { - if (conf_log) { + if (logdata->log_to_file) { filename = log_build_filename(logdata, destination); if (!filename) return NULL; @@ -1084,7 +1084,7 @@ static list_t *log_backread(log_t *log, const char *storename, const char *dest) return ret; } - if (!conf_log) { + if (!log->log_to_file) { mylog(LOG_DEBUG, "No conf_log, not backlogging"); return NULL; } @@ -1144,7 +1144,7 @@ static int _log_write(log_t *logdata, logstore_t *store, } } - if (!conf_log) + if (!logdata->log_to_file) return 0; logfile_t *lf = list_get_last(&store->file_group); @@ -1212,6 +1212,7 @@ log_t *log_new(struct bipuser *user, const char *network) logdata->buffer[LOGLINE_MAXLEN - 1] = 0; // debug logdata->buffer[LOGLINE_MAXLEN] = 0; logdata->connected = 0; + logdata->log_to_file = conf_log; if (!log_all_logs) log_all_logs = list_new(list_ptr_cmp); list_add_last(log_all_logs, logdata); diff --git a/src/log.h b/src/log.h index 4e73275..dbbc4a6 100644 --- a/src/log.h +++ b/src/log.h @@ -58,6 +58,7 @@ typedef struct log int connected; int backlogging; int lastfile_seeked; + int log_to_file; struct bipuser *user; } log_t;