improved daemon logging suggestion for libbrillo users

9 views
Skip to first unread message

Mike Frysinger

unread,
Aug 17, 2017, 4:11:57 PM8/17/17
to chromium-os-dev
scenario:
people write CrOS daemons/programs and want to log the output to syslog.  but they also want to see the output in the terminal when running it by hand.  what to do?

existing solutions are no fun and non-standard:
- don't do anything and force people to always read /var/log/messages (or wherever)
- always log to syslog & stderr (and waste overhead at runtime)
- add some CLI option like --log_to_stderr and change behavior based on that
- do some tty detection by hand and select stderr dynamically

new solution is fun:
always pass kLogToSyslog | kLogToStderrIfTty !  this assumes you normally want things to go to syslog of course :).  libbrillo will take care of detecting if the command is being run from the command line by a dev (isatty on stdin), and if so, it will also send output to stderr.  otherwise, stderr stays quiet.

i think this scenario describes most of the users in our code base, so people should update as they see fit.
-mike
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages