diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-06-15 13:38:46 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-06-19 08:43:59 -0400 |
| commit | f8507817cf19d621cefd1d0310925ad07ec4646e (patch) | |
| tree | 3ea82f53181723fb6e4ff91a417f9bc73f019a3f /lib/command.c | |
| parent | 1f1432364911625d5abd6384b190a2d75c37120f (diff) | |
lib: Add new cli to specify where to output logs on startup
When we are starting a daemon, allow the user to specify:
--log <stdout|syslog|file:file_name>
This can be used on early startup to put the log files
where the end user wants them to show up.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/command.c b/lib/command.c index a8e61c6bb4..32b052c36c 100644 --- a/lib/command.c +++ b/lib/command.c @@ -2429,7 +2429,8 @@ static int set_log_file(struct vty *vty, const char *fname, int loglevel) XFREE(MTYPE_TMP, p); if (!ret) { - vty_out(vty, "can't open logfile %s\n", fname); + if (vty) + vty_out(vty, "can't open logfile %s\n", fname); return CMD_WARNING_CONFIG_FAILED; } @@ -2445,6 +2446,26 @@ static int set_log_file(struct vty *vty, const char *fname, int loglevel) return CMD_SUCCESS; } +void command_setup_early_logging(const char *option) +{ + char *token; + + if (strcmp(option, "stdout") == 0) { + zlog_set_level(ZLOG_DEST_STDOUT, zlog_default->default_lvl); + return; + } + + if (strcmp(option, "syslog") == 0) { + zlog_set_level(ZLOG_DEST_SYSLOG, zlog_default->default_lvl); + return; + } + + token = strstr(option, ":"); + token++; + + set_log_file(NULL, token, zlog_default->default_lvl); +} + DEFUN (config_log_file, config_log_file_cmd, "log file FILENAME [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]", |
