connection: allow to disable / enable log (#211)
add option 'log' (true/false) in connection section, this option overrides the global 'log' option. Thanks to jj !
This commit is contained in:
parent
2e49437ed7
commit
87da44e583
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
13
src/log.c
13
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);
|
||||
|
Loading…
Reference in New Issue
Block a user