From a1a7e930ebd75e82668f7868fa7cb9fdcb2a043d Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 15 Aug 2017 23:49:40 -0400 Subject: syslog: new option to log in interactive sessions Developers often want to run programs that log to stderr when they run them by hand, but use syslog when run as a daemon. Add a new flag that turns on stderr logging only when stdin is a tty. BUG=None TEST=unittests pass Change-Id: I8086a4613099c873800188415b97cc7b241ab847 Reviewed-on: https://chromium-review.googlesource.com/616449 Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger Reviewed-by: Dan Erat --- brillo/syslog_logging.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'brillo/syslog_logging.h') diff --git a/brillo/syslog_logging.h b/brillo/syslog_logging.h index b054259..04b3253 100644 --- a/brillo/syslog_logging.h +++ b/brillo/syslog_logging.h @@ -12,9 +12,14 @@ namespace brillo { enum InitFlags { + // Always log to syslog. kLogToSyslog = 1, + // Always log to stderr. kLogToStderr = 2, + // Include message header in log lines. kLogHeader = 4, + // Log to stderr if stdin is a tty (e.g. command line). + kLogToStderrIfTty = 8, }; // Initialize logging subsystem. |init_flags| is a bitfield, with bits defined -- cgit v1.2.3