1
0
forked from bip/bip

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:
Yoann Guillot 2011-04-05 23:43:05 +02:00 committed by Pierre-Louis Bonicoli
parent 2e49437ed7
commit 87da44e583
5 changed files with 17 additions and 6 deletions

View File

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

View File

@ -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)

View File

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

View File

@ -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);

View File

@ -58,6 +58,7 @@ typedef struct log
int connected;
int backlogging;
int lastfile_seeked;
int log_to_file;
struct bipuser *user;
} log_t;