3 * Copyright (C) 2019 Cumulus Networks, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "lib/log_vty.h"
26 #include "lib/zlog_targets.h"
27 #include "lib/zlog_5424.h"
28 #include "lib/lib_errors.h"
29 #include "lib/printfrr.h"
30 #include "lib/systemd.h"
32 #ifndef VTYSH_EXTRACT_PL
33 #include "lib/log_vty_clippy.c"
36 #define ZLOG_MAXLVL(a, b) MAX(a, b)
38 DEFINE_HOOK(zlog_rotate
, (), ());
39 DEFINE_HOOK(zlog_cli_show
, (struct vty
* vty
), (vty
));
41 static unsigned logmsgs_with_persist_bt
;
43 static const int log_default_lvl
= LOG_DEBUG
;
45 static int log_config_stdout_lvl
= ZLOG_DISABLED
;
46 static int log_config_syslog_lvl
= ZLOG_DISABLED
;
47 static int log_cmdline_stdout_lvl
= ZLOG_DISABLED
;
48 static int log_cmdline_syslog_lvl
= ZLOG_DISABLED
;
50 static struct zlog_cfg_file zt_file_cmdline
= {
51 .prio_min
= ZLOG_DISABLED
,
53 static struct zlog_cfg_file zt_file
= {
54 .prio_min
= ZLOG_DISABLED
,
56 static struct zlog_cfg_filterfile zt_filterfile
= {
58 .prio_min
= ZLOG_DISABLED
,
62 static struct zlog_cfg_file zt_stdout_file
= {
63 .prio_min
= ZLOG_DISABLED
,
65 static struct zlog_cfg_5424 zt_stdout_journald
= {
66 .prio_min
= ZLOG_DISABLED
,
68 .fmt
= ZLOG_FMT_JOURNALD
,
69 .dst
= ZLOG_5424_DST_UNIX
,
70 .filename
= "/run/systemd/journal/socket",
72 /* this can't be changed through config since this target substitutes
73 * in for the "plain" stdout target
75 .facility
= LOG_DAEMON
,
82 static bool stdout_journald_in_use
;
84 const char *zlog_progname
;
85 static const char *zlog_protoname
;
87 static const struct facility_map
{
91 } syslog_facilities
[] = {
92 {LOG_KERN
, "kern", 1},
93 {LOG_USER
, "user", 2},
94 {LOG_MAIL
, "mail", 1},
95 {LOG_DAEMON
, "daemon", 1},
96 {LOG_AUTH
, "auth", 1},
97 {LOG_SYSLOG
, "syslog", 1},
99 {LOG_NEWS
, "news", 1},
100 {LOG_UUCP
, "uucp", 2},
101 {LOG_CRON
, "cron", 1},
105 {LOG_LOCAL0
, "local0", 6},
106 {LOG_LOCAL1
, "local1", 6},
107 {LOG_LOCAL2
, "local2", 6},
108 {LOG_LOCAL3
, "local3", 6},
109 {LOG_LOCAL4
, "local4", 6},
110 {LOG_LOCAL5
, "local5", 6},
111 {LOG_LOCAL6
, "local6", 6},
112 {LOG_LOCAL7
, "local7", 6},
116 static const char * const zlog_priority
[] = {
117 "emergencies", "alerts", "critical", "errors", "warnings",
118 "notifications", "informational", "debugging", NULL
,
121 const char *zlog_priority_str(int priority
)
123 if (priority
> LOG_DEBUG
)
125 return zlog_priority
[priority
];
128 const char *facility_name(int facility
)
130 const struct facility_map
*fm
;
132 for (fm
= syslog_facilities
; fm
->name
; fm
++)
133 if (fm
->facility
== facility
)
138 int facility_match(const char *str
)
140 const struct facility_map
*fm
;
142 for (fm
= syslog_facilities
; fm
->name
; fm
++)
143 if (!strncmp(str
, fm
->name
, fm
->match
))
148 int log_level_match(const char *s
)
152 for (level
= 0; zlog_priority
[level
] != NULL
; level
++)
153 if (!strncmp(s
, zlog_priority
[level
], 2))
155 return ZLOG_DISABLED
;
158 void zlog_rotate(void)
160 zlog_file_rotate(&zt_file
);
161 zlog_file_rotate(&zt_filterfile
.parent
);
162 hook_call(zlog_rotate
);
166 void log_show_syslog(struct vty
*vty
)
168 int level
= zlog_syslog_get_prio_min();
170 vty_out(vty
, "Syslog logging: ");
171 if (level
== ZLOG_DISABLED
)
172 vty_out(vty
, "disabled\n");
174 vty_out(vty
, "level %s, facility %s, ident %s\n",
175 zlog_priority
[level
],
176 facility_name(zlog_syslog_get_facility()),
180 DEFUN_NOSH (show_logging
,
184 "Show current logging configuration\n")
188 log_show_syslog(vty
);
190 stdout_prio
= stdout_journald_in_use
? zt_stdout_journald
.prio_min
191 : zt_stdout_file
.prio_min
;
193 vty_out(vty
, "Stdout logging: ");
194 if (stdout_prio
== ZLOG_DISABLED
)
195 vty_out(vty
, "disabled");
197 vty_out(vty
, "level %s", zlog_priority
[stdout_prio
]);
200 vty_out(vty
, "File logging: ");
201 if (zt_file
.prio_min
== ZLOG_DISABLED
|| !zt_file
.filename
)
202 vty_out(vty
, "disabled");
204 vty_out(vty
, "level %s, filename %s",
205 zlog_priority
[zt_file
.prio_min
], zt_file
.filename
);
208 if (zt_filterfile
.parent
.prio_min
!= ZLOG_DISABLED
209 && zt_filterfile
.parent
.filename
)
210 vty_out(vty
, "Filtered-file logging: level %s, filename %s\n",
211 zlog_priority
[zt_filterfile
.parent
.prio_min
],
212 zt_filterfile
.parent
.filename
);
214 if (log_cmdline_syslog_lvl
!= ZLOG_DISABLED
)
216 "From command line: \"--log syslog --log-level %s\"\n",
217 zlog_priority
[log_cmdline_syslog_lvl
]);
218 if (log_cmdline_stdout_lvl
!= ZLOG_DISABLED
)
220 "From command line: \"--log stdout --log-level %s\"\n",
221 zlog_priority
[log_cmdline_stdout_lvl
]);
222 if (zt_file_cmdline
.prio_min
!= ZLOG_DISABLED
)
224 "From command line: \"--log file:%s --log-level %s\"\n",
225 zt_file_cmdline
.filename
,
226 zlog_priority
[zt_file_cmdline
.prio_min
]);
228 vty_out(vty
, "Protocol name: %s\n", zlog_protoname
);
229 vty_out(vty
, "Record priority: %s\n",
230 (zt_file
.record_priority
? "enabled" : "disabled"));
231 vty_out(vty
, "Timestamp precision: %d\n", zt_file
.ts_subsec
);
233 hook_call(zlog_cli_show
, vty
);
237 static void log_stdout_apply_level(void)
241 maxlvl
= ZLOG_MAXLVL(log_config_stdout_lvl
, log_cmdline_stdout_lvl
);
243 if (stdout_journald_in_use
) {
244 zt_stdout_journald
.prio_min
= maxlvl
;
245 zlog_5424_apply_meta(&zt_stdout_journald
);
247 zt_stdout_file
.prio_min
= maxlvl
;
248 zlog_file_set_other(&zt_stdout_file
);
252 DEFPY (config_log_stdout
,
253 config_log_stdout_cmd
,
254 "log stdout [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>$levelarg]",
256 "Set stdout logging level\n"
262 level
= log_level_match(levelarg
);
263 if (level
== ZLOG_DISABLED
)
264 return CMD_ERR_NO_MATCH
;
266 level
= log_default_lvl
;
268 log_config_stdout_lvl
= level
;
269 log_stdout_apply_level();
273 DEFUN (no_config_log_stdout
,
274 no_config_log_stdout_cmd
,
275 "no log stdout [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
278 "Cancel logging to stdout\n"
281 log_config_stdout_lvl
= ZLOG_DISABLED
;
282 log_stdout_apply_level();
286 DEFUN_HIDDEN (config_log_monitor
,
287 config_log_monitor_cmd
,
288 "log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
290 "Set terminal line (monitor) logging level\n"
293 vty_out(vty
, "%% \"log monitor\" is deprecated and does nothing.\n");
297 DEFUN_HIDDEN (no_config_log_monitor
,
298 no_config_log_monitor_cmd
,
299 "no log monitor [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
302 "Disable terminal line (monitor) logging\n"
308 DEFPY_NOSH (debug_uid_backtrace
,
309 debug_uid_backtrace_cmd
,
310 "[no] debug unique-id UID backtrace",
313 "Options per individual log message, by unique ID\n"
314 "Log message unique ID (XXXXX-XXXXX)\n"
315 "Add backtrace to log when message is printed\n")
317 struct xrefdata search
, *xrd
;
318 struct xrefdata_logmsg
*xrdl
;
321 strlcpy(search
.uid
, uid
, sizeof(search
.uid
));
322 xrd
= xrefdata_uid_find(&xrefdata_uid
, &search
);
325 return CMD_ERR_NOTHING_TODO
;
327 if (xrd
->xref
->type
!= XREFT_LOGMSG
) {
328 vty_out(vty
, "%% ID \"%s\" is not a log message\n", uid
);
331 xrdl
= container_of(xrd
, struct xrefdata_logmsg
, xrefdata
);
333 flag
= (vty
->node
== CONFIG_NODE
) ? LOGMSG_FLAG_PERSISTENT
334 : LOGMSG_FLAG_EPHEMERAL
;
336 if ((xrdl
->fl_print_bt
& flag
) == (no
? 0 : flag
))
338 if (flag
== LOGMSG_FLAG_PERSISTENT
)
339 logmsgs_with_persist_bt
+= no
? -1 : 1;
341 xrdl
->fl_print_bt
^= flag
;
345 static int set_log_file(struct zlog_cfg_file
*target
, struct vty
*vty
,
346 const char *fname
, int loglevel
)
348 char path
[MAXPATHLEN
+ 1];
349 const char *fullpath
;
353 /* Path detection. */
354 if (!IS_DIRECTORY_SEP(*fname
)) {
355 char cwd
[MAXPATHLEN
+ 1];
357 cwd
[MAXPATHLEN
] = '\0';
359 if (getcwd(cwd
, MAXPATHLEN
) == NULL
) {
360 flog_err_sys(EC_LIB_SYSTEM_CALL
,
361 "config_log_file: Unable to alloc mem!");
362 return CMD_WARNING_CONFIG_FAILED
;
365 int pr
= snprintf(path
, sizeof(path
), "%s/%s", cwd
, fname
);
366 if (pr
< 0 || (unsigned int)pr
>= sizeof(path
)) {
369 "%s: Path too long ('%s/%s'); system maximum is %u",
370 __func__
, cwd
, fname
, MAXPATHLEN
);
371 return CMD_WARNING_CONFIG_FAILED
;
378 target
->prio_min
= loglevel
;
379 ok
= zlog_file_set_filename(target
, fullpath
);
383 vty_out(vty
, "can't open logfile %s\n", fname
);
384 return CMD_WARNING_CONFIG_FAILED
;
389 void command_setup_early_logging(const char *dest
, const char *level
)
397 nlevel
= log_level_match(level
);
399 if (nlevel
== ZLOG_DISABLED
) {
400 fprintf(stderr
, "invalid log level \"%s\"\n", level
);
404 nlevel
= log_default_lvl
;
409 sep
= strchr(dest
, ':');
410 len
= sep
? (int)(sep
- dest
) : (int)strlen(dest
);
412 snprintfrr(type
, sizeof(type
), "%.*s", len
, dest
);
414 if (strcmp(type
, "stdout") == 0) {
415 log_cmdline_stdout_lvl
= nlevel
;
416 log_stdout_apply_level();
419 if (strcmp(type
, "syslog") == 0) {
420 log_cmdline_syslog_lvl
= nlevel
;
421 zlog_syslog_set_prio_min(ZLOG_MAXLVL(log_config_syslog_lvl
,
422 log_cmdline_syslog_lvl
));
425 if (strcmp(type
, "file") == 0 && sep
) {
427 set_log_file(&zt_file_cmdline
, NULL
, sep
, nlevel
);
431 fprintf(stderr
, "invalid log target \"%s\" (\"%s\")\n", type
, dest
);
435 DEFUN (clear_log_cmdline
,
436 clear_log_cmdline_cmd
,
437 "clear log cmdline-targets",
440 "Disable log targets specified at startup by --log option\n")
442 zt_file_cmdline
.prio_min
= ZLOG_DISABLED
;
443 zlog_file_set_other(&zt_file_cmdline
);
445 log_cmdline_syslog_lvl
= ZLOG_DISABLED
;
446 zlog_syslog_set_prio_min(ZLOG_MAXLVL(log_config_syslog_lvl
,
447 log_cmdline_syslog_lvl
));
449 log_cmdline_stdout_lvl
= ZLOG_DISABLED
;
450 log_stdout_apply_level();
455 DEFPY (config_log_file
,
457 "log file FILENAME [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>$levelarg]",
463 int level
= log_default_lvl
;
466 level
= log_level_match(levelarg
);
467 if (level
== ZLOG_DISABLED
)
468 return CMD_ERR_NO_MATCH
;
470 return set_log_file(&zt_file
, vty
, filename
, level
);
473 DEFUN (no_config_log_file
,
474 no_config_log_file_cmd
,
475 "no log file [FILENAME [LEVEL]]",
478 "Cancel logging to file\n"
479 "Logging file name\n"
482 zt_file
.prio_min
= ZLOG_DISABLED
;
483 zlog_file_set_other(&zt_file
);
487 DEFPY (config_log_syslog
,
488 config_log_syslog_cmd
,
489 "log syslog [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>$levelarg]",
491 "Set syslog logging level\n"
497 level
= log_level_match(levelarg
);
499 if (level
== ZLOG_DISABLED
)
500 return CMD_ERR_NO_MATCH
;
502 level
= log_default_lvl
;
504 log_config_syslog_lvl
= level
;
505 zlog_syslog_set_prio_min(ZLOG_MAXLVL(log_config_syslog_lvl
,
506 log_cmdline_syslog_lvl
));
510 DEFUN (no_config_log_syslog
,
511 no_config_log_syslog_cmd
,
512 "no log syslog [<kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>] [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>]",
515 "Cancel logging to syslog\n"
519 log_config_syslog_lvl
= ZLOG_DISABLED
;
520 zlog_syslog_set_prio_min(ZLOG_MAXLVL(log_config_syslog_lvl
,
521 log_cmdline_syslog_lvl
));
525 DEFPY (config_log_facility
,
526 config_log_facility_cmd
,
527 "log facility <kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>$facilityarg",
529 "Facility parameter for syslog messages\n"
532 int facility
= facility_match(facilityarg
);
534 zlog_syslog_set_facility(facility
);
538 DEFUN (no_config_log_facility
,
539 no_config_log_facility_cmd
,
540 "no log facility [<kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7>]",
543 "Reset syslog facility to default (daemon)\n"
546 zlog_syslog_set_facility(LOG_DAEMON
);
550 DEFUN (config_log_record_priority
,
551 config_log_record_priority_cmd
,
552 "log record-priority",
554 "Log the priority of the message within the message\n")
556 zt_file
.record_priority
= true;
557 zlog_file_set_other(&zt_file
);
558 if (!stdout_journald_in_use
) {
559 zt_stdout_file
.record_priority
= true;
560 zlog_file_set_other(&zt_stdout_file
);
562 zt_filterfile
.parent
.record_priority
= true;
563 zlog_file_set_other(&zt_filterfile
.parent
);
567 DEFUN (no_config_log_record_priority
,
568 no_config_log_record_priority_cmd
,
569 "no log record-priority",
572 "Do not log the priority of the message within the message\n")
574 zt_file
.record_priority
= false;
575 zlog_file_set_other(&zt_file
);
576 if (!stdout_journald_in_use
) {
577 zt_stdout_file
.record_priority
= false;
578 zlog_file_set_other(&zt_stdout_file
);
580 zt_filterfile
.parent
.record_priority
= false;
581 zlog_file_set_other(&zt_filterfile
.parent
);
585 DEFPY (config_log_timestamp_precision
,
586 config_log_timestamp_precision_cmd
,
587 "log timestamp precision (0-6)",
589 "Timestamp configuration\n"
590 "Set the timestamp precision\n"
591 "Number of subsecond digits\n")
593 zt_file
.ts_subsec
= precision
;
594 zlog_file_set_other(&zt_file
);
595 if (!stdout_journald_in_use
) {
596 zt_stdout_file
.ts_subsec
= precision
;
597 zlog_file_set_other(&zt_stdout_file
);
599 zt_filterfile
.parent
.ts_subsec
= precision
;
600 zlog_file_set_other(&zt_filterfile
.parent
);
604 DEFUN (no_config_log_timestamp_precision
,
605 no_config_log_timestamp_precision_cmd
,
606 "no log timestamp precision [(0-6)]",
609 "Timestamp configuration\n"
610 "Reset the timestamp precision to the default value of 0\n"
611 "Number of subsecond digits\n")
613 zt_file
.ts_subsec
= 0;
614 zlog_file_set_other(&zt_file
);
615 if (!stdout_journald_in_use
) {
616 zt_stdout_file
.ts_subsec
= 0;
617 zlog_file_set_other(&zt_stdout_file
);
619 zt_filterfile
.parent
.ts_subsec
= 0;
620 zlog_file_set_other(&zt_filterfile
.parent
);
624 DEFPY (config_log_ec
,
626 "[no] log error-category",
629 "Prefix log message text with [EC 9999] code\n")
631 zlog_set_prefix_ec(!no
);
635 DEFPY (config_log_xid
,
637 "[no] log unique-id",
640 "Prefix log message text with [XXXXX-XXXXX] identifier\n")
642 zlog_set_prefix_xid(!no
);
646 DEFPY (config_log_filterfile
,
647 config_log_filterfile_cmd
,
648 "log filtered-file FILENAME [<emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>$levelarg]",
650 "Logging to file with string filter\n"
654 int level
= log_default_lvl
;
657 level
= log_level_match(levelarg
);
658 if (level
== ZLOG_DISABLED
)
659 return CMD_ERR_NO_MATCH
;
661 return set_log_file(&zt_filterfile
.parent
, vty
, filename
, level
);
664 DEFUN (no_config_log_filterfile
,
665 no_config_log_filterfile_cmd
,
666 "no log filtered-file [FILENAME [LEVEL]]",
669 "Cancel logging to file with string filter\n"
670 "Logging file name\n"
673 zt_filterfile
.parent
.prio_min
= ZLOG_DISABLED
;
674 zlog_file_set_other(&zt_filterfile
.parent
);
680 "[no] log filter-text WORD$filter",
684 "String to filter by\n")
689 ret
= zlog_filter_del(filter
);
691 ret
= zlog_filter_add(filter
);
694 vty_out(vty
, "%% filter table full\n");
696 } else if (ret
!= 0) {
697 vty_out(vty
, "%% failed to %s log filter\n",
698 (no
? "remove" : "apply"));
702 vty_out(vty
, " %s\n", filter
);
706 /* Clear all log filters */
707 DEFPY (log_filter_clear
,
708 log_filter_clear_cmd
,
709 "clear log filter-text",
718 /* Show log filter */
719 DEFPY (show_log_filter
,
721 "show logging filter-text",
723 "Show current logging configuration\n"
726 char log_filters
[ZLOG_FILTERS_MAX
* (ZLOG_FILTER_LENGTH_MAX
+ 3)] = "";
729 len
= zlog_filter_dump(log_filters
, sizeof(log_filters
));
732 vty_out(vty
, "%% failed to get filters\n");
737 vty_out(vty
, "%s", log_filters
);
742 /* Enable/disable 'immediate' mode, with no output buffering */
743 DEFPY (log_immediate_mode
,
744 log_immediate_mode_cmd
,
745 "[no] log immediate-mode",
748 "Output immediately, without buffering")
750 zlog_set_immediate(!no
);
754 void log_config_write(struct vty
*vty
)
756 bool show_cmdline_hint
= false;
758 if (zt_file
.prio_min
!= ZLOG_DISABLED
&& zt_file
.filename
) {
759 vty_out(vty
, "log file %s", zt_file
.filename
);
761 if (zt_file
.prio_min
!= log_default_lvl
)
762 vty_out(vty
, " %s", zlog_priority
[zt_file
.prio_min
]);
766 if (zt_filterfile
.parent
.prio_min
!= ZLOG_DISABLED
767 && zt_filterfile
.parent
.filename
) {
768 vty_out(vty
, "log filtered-file %s",
769 zt_filterfile
.parent
.filename
);
771 if (zt_filterfile
.parent
.prio_min
!= log_default_lvl
)
773 zlog_priority
[zt_filterfile
.parent
.prio_min
]);
777 if (log_config_stdout_lvl
!= ZLOG_DISABLED
) {
778 vty_out(vty
, "log stdout");
780 if (log_config_stdout_lvl
!= log_default_lvl
)
782 zlog_priority
[log_config_stdout_lvl
]);
786 if (log_config_syslog_lvl
!= ZLOG_DISABLED
) {
787 vty_out(vty
, "log syslog");
789 if (log_config_syslog_lvl
!= log_default_lvl
)
791 zlog_priority
[log_config_syslog_lvl
]);
795 if (log_cmdline_syslog_lvl
!= ZLOG_DISABLED
) {
797 "! \"log syslog %s\" enabled by \"--log\" startup option\n",
798 zlog_priority
[log_cmdline_syslog_lvl
]);
799 show_cmdline_hint
= true;
801 if (log_cmdline_stdout_lvl
!= ZLOG_DISABLED
) {
803 "! \"log stdout %s\" enabled by \"--log\" startup option\n",
804 zlog_priority
[log_cmdline_stdout_lvl
]);
805 show_cmdline_hint
= true;
807 if (zt_file_cmdline
.prio_min
!= ZLOG_DISABLED
) {
809 "! \"log file %s %s\" enabled by \"--log\" startup option\n",
810 zt_file_cmdline
.filename
,
811 zlog_priority
[zt_file_cmdline
.prio_min
]);
812 show_cmdline_hint
= true;
814 if (show_cmdline_hint
)
816 "! use \"clear log cmdline-targets\" to remove this target\n");
818 if (zlog_syslog_get_facility() != LOG_DAEMON
)
819 vty_out(vty
, "log facility %s\n",
820 facility_name(zlog_syslog_get_facility()));
822 if (zt_file
.record_priority
== 1)
823 vty_out(vty
, "log record-priority\n");
825 if (zt_file
.ts_subsec
> 0)
826 vty_out(vty
, "log timestamp precision %d\n",
829 if (!zlog_get_prefix_ec())
830 vty_out(vty
, "no log error-category\n");
831 if (!zlog_get_prefix_xid())
832 vty_out(vty
, "no log unique-id\n");
834 if (logmsgs_with_persist_bt
) {
835 struct xrefdata
*xrd
;
836 struct xrefdata_logmsg
*xrdl
;
840 frr_each (xrefdata_uid
, &xrefdata_uid
, xrd
) {
841 if (xrd
->xref
->type
!= XREFT_LOGMSG
)
844 xrdl
= container_of(xrd
, struct xrefdata_logmsg
,
846 if (xrdl
->fl_print_bt
& LOGMSG_FLAG_PERSISTENT
)
847 vty_out(vty
, "debug unique-id %s backtrace\n",
853 static int log_vty_init(const char *progname
, const char *protoname
,
854 unsigned short instance
, uid_t uid
, gid_t gid
)
856 zlog_progname
= progname
;
857 zlog_protoname
= protoname
;
859 zlog_set_prefix_ec(true);
860 zlog_set_prefix_xid(true);
862 zlog_filterfile_init(&zt_filterfile
);
864 if (sd_stdout_is_journal
) {
865 stdout_journald_in_use
= true;
866 zlog_5424_init(&zt_stdout_journald
);
867 zlog_5424_apply_dst(&zt_stdout_journald
);
869 zlog_file_set_fd(&zt_stdout_file
, STDOUT_FILENO
);
873 __attribute__((_CONSTRUCTOR(475))) static void log_vty_preinit(void)
875 hook_register(zlog_init
, log_vty_init
);
878 void log_cmd_init(void)
880 install_element(VIEW_NODE
, &show_logging_cmd
);
881 install_element(ENABLE_NODE
, &clear_log_cmdline_cmd
);
883 install_element(CONFIG_NODE
, &config_log_stdout_cmd
);
884 install_element(CONFIG_NODE
, &no_config_log_stdout_cmd
);
885 install_element(CONFIG_NODE
, &config_log_monitor_cmd
);
886 install_element(CONFIG_NODE
, &no_config_log_monitor_cmd
);
887 install_element(CONFIG_NODE
, &config_log_file_cmd
);
888 install_element(CONFIG_NODE
, &no_config_log_file_cmd
);
889 install_element(CONFIG_NODE
, &config_log_syslog_cmd
);
890 install_element(CONFIG_NODE
, &no_config_log_syslog_cmd
);
891 install_element(CONFIG_NODE
, &config_log_facility_cmd
);
892 install_element(CONFIG_NODE
, &no_config_log_facility_cmd
);
893 install_element(CONFIG_NODE
, &config_log_record_priority_cmd
);
894 install_element(CONFIG_NODE
, &no_config_log_record_priority_cmd
);
895 install_element(CONFIG_NODE
, &config_log_timestamp_precision_cmd
);
896 install_element(CONFIG_NODE
, &no_config_log_timestamp_precision_cmd
);
897 install_element(CONFIG_NODE
, &config_log_ec_cmd
);
898 install_element(CONFIG_NODE
, &config_log_xid_cmd
);
900 install_element(VIEW_NODE
, &show_log_filter_cmd
);
901 install_element(CONFIG_NODE
, &log_filter_cmd
);
902 install_element(CONFIG_NODE
, &log_filter_clear_cmd
);
903 install_element(CONFIG_NODE
, &config_log_filterfile_cmd
);
904 install_element(CONFIG_NODE
, &no_config_log_filterfile_cmd
);
905 install_element(CONFIG_NODE
, &log_immediate_mode_cmd
);
907 install_element(ENABLE_NODE
, &debug_uid_backtrace_cmd
);
908 install_element(CONFIG_NODE
, &debug_uid_backtrace_cmd
);