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:
Lennart Poettering
2018-11-20 11:18:22 +01:00
parent afe44c8ffd
commit 6bf3c61c57
44 changed files with 54 additions and 126 deletions
+10
View File
@@ -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();
}
+2
View File
@@ -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);