# HG changeset patch # User David Demelier # Date 1624179372 -7200 # Node ID e76044862cceaa32fb7bd112797be58779e912a4 # Parent 4b53eb6fff7348f6db279a2fbfdd7189277a4731 irccd: advertise irc_log_set_template function diff -r 4b53eb6fff73 -r e76044862cce lib/irccd/log.c --- a/lib/irccd/log.c Sun Jun 20 10:38:21 2021 +0200 +++ b/lib/irccd/log.c Sun Jun 20 10:56:12 2021 +0200 @@ -26,6 +26,8 @@ #include "log.h" #include "subst.h" +#define DEFAULT_TEMPLATE "#{message}" + enum level { LEVEL_INFO, LEVEL_WARN, @@ -34,7 +36,7 @@ static FILE *out, *err; static int verbosity; -static char tmpl[512] = "#{message}"; +static char tmpl[512] = DEFAULT_TEMPLATE; static void handler_files(enum level level, const char *line) @@ -158,7 +160,7 @@ void irc_log_set_template(const char *fmt) { - strlcpy(tmpl, fmt, sizeof (tmpl)); + strlcpy(tmpl, fmt ? fmt : DEFAULT_TEMPLATE, sizeof (tmpl)); } void diff -r 4b53eb6fff73 -r e76044862cce man/libirccd-log.3 --- a/man/libirccd-log.3 Sun Jun 20 10:38:21 2021 +0200 +++ b/man/libirccd-log.3 Sun Jun 20 10:56:12 2021 +0200 @@ -34,6 +34,8 @@ .Ft void .Fn irc_log_set_verbose "int verbose" .Ft void +.Fn irc_log_set_template "const char *tmpl" +.Ft void .Fn irc_log_info "const char *fmt, ..." .Ft void .Fn irc_log_warn "const char *fmt, ..." @@ -69,11 +71,20 @@ .Pp The .Fn irc_log_set_verbose -change the verbosity to on if +changes the verbosity to on if .Fa verbose is greater than 0 (which is the default). .Pp The +.Fn irc_log_set_template +changes the format string used to log entries with the help of +.Xr libirccd-subst 3 +routines. Passing NULL as +.Ar tmpl +resets the default format to +.Dq #{message} +.Pp +The .Fn irc_log_info uses the .Xr printf 3