1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-04 05:23:13 +02:00

Automatically add default log block that logs everything if no log

block to disk is present.
Also update the English example.conf.

Both may need some default filtering (or not)...
This commit is contained in:
Bram Matthys
2021-09-24 11:29:36 +02:00
parent 9852ec9991
commit 56c3b4ced6
4 changed files with 40 additions and 14 deletions
+8 -14
View File
@@ -265,20 +265,14 @@ drpass {
* See also https://www.unrealircd.org/docs/Log_block
*/
/* This is a good default, it logs everything */
log "ircd.log" {
flags {
oper;
connects;
server-connects;
kills;
errors;
flood;
sadmin-commands;
chg-commands;
oper-override;
tkl;
spamfilter;
/* This is a good default, it logs nearly everything */
log {
source {
all;
!SOMETHING;
}
destination {
file "ircd.log" { maxsize 100M; }
}
}
+1
View File
@@ -1126,6 +1126,7 @@ extern LogData *log_data_link_block(ConfigItem_link *link);
extern LogData *log_data_tkl(const char *key, TKL *tkl);
extern LogData *log_data_tls_error(void);
extern void log_blocks_switchover(void);
extern void postconf_defaults_log_block(void);
extern LogLevel log_level_stringtoval(const char *str);
extern const char *log_level_valtostring(LogLevel loglevel);
extern LogLevel log_level_stringtoval(const char *str);
+2
View File
@@ -1847,6 +1847,8 @@ void postconf_defaults(void)
safe_strdup(tk->set_by, conf_me->name ? conf_me->name : "~server~");
}
}
postconf_defaults_log_block();
}
void postconf_fixes(void)
+29
View File
@@ -1660,3 +1660,32 @@ void log_blocks_switchover(void)
* blocks, then we would have opened the file twice.
* Better to use an extra layer to keep track of files.
*/
void postconf_defaults_log_block(void)
{
Log *l;
LogSource *ls;
/* Is there any log block to disk? Then nothing to do. */
if (logs[LOG_DEST_OTHER])
return;
unreal_log(ULOG_WARNING, "log", "NO_DISK_LOG_BLOCK", NULL,
"No log { } block found that logs to disk -- "
"logging everything in text format to 'ircd.log'");
/* Create a default log block */
l = safe_alloc(sizeof(Log));
l->logfd = -1;
l->type = LOG_TYPE_TEXT; /* text */
l->maxsize = 100000000; /* maxsize 100M */
safe_strdup(l->file, "ircd.log");
convert_to_absolute_path(&l->file, LOGDIR);
AddListItem(l, logs[LOG_DEST_OTHER]);
/* And the source filter */
ls = add_log_source("all");
AppendListItem(ls, l->sources);
ls = add_log_source("!SOMETHING");
AppendListItem(ls, l->sources);
}