log: introduce new helper call log_setup_service()
Let's reduce the common boilerplate and have a single setup function used by all service code to setup logging.
This commit is contained in:
@@ -1337,3 +1337,13 @@ int log_dup_console(void) {
|
||||
console_fd = copy;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void log_setup_service(void) {
|
||||
/* Sets up logging the way it is most appropriate for running a program as a service. Note that using this
|
||||
* doesn't make the binary unsuitable for invocation on the command line, as log output will still go to the
|
||||
* terminal if invoked interactively. */
|
||||
|
||||
log_set_target(LOG_TARGET_AUTO);
|
||||
log_parse_environment();
|
||||
log_open();
|
||||
}
|
||||
|
||||
@@ -318,3 +318,5 @@ int log_syntax_invalid_utf8_internal(
|
||||
})
|
||||
|
||||
#define DEBUG_LOGGING _unlikely_(log_get_max_level() >= LOG_DEBUG)
|
||||
|
||||
void log_setup_service(void);
|
||||
|
||||
Reference in New Issue
Block a user