log: minimize includes in log.h

log.h really should only include the bare minimum of other headers, as
it is really pulled into pretty much everything else and already in
itself one of the most basic pieces of code we have.

Let's hence drop inclusion of:

1. sd-id128.h because it's entirely unneeded in current log.h
2. errno.h, dito.
3. sys/signalfd.h which we can replace by a simple struct forward
   declaration
4. process-util.h which was needed for getpid_cached() which we now hide
   in a funciton log_emergency_level() instead, which nicely abstracts
   the details away.
5. sys/socket.h which was needed for struct iovec, but a simple struct
   forward declaration suffices for that too.

Ultimately this actually makes our source tree larger (since users of
the functionality above must now include it themselves, log.h won't do
that for them), but I think it helps to untangle our web of includes a
tiny bit.

(Background: I'd like to isolate the generic bits of src/basic/ enough
so that we can do a git submodule import into casync for it)
This commit is contained in:
Lennart Poettering
2018-01-11 14:44:31 +01:00
parent 1a86b08513
commit dccca82b1a
82 changed files with 127 additions and 25 deletions
+7 -1
View File
@@ -1239,7 +1239,6 @@ void log_received_signal(int level, const struct signalfd_siginfo *si) {
log_full(level,
"Received SIG%s.",
signal_to_string(si->ssi_signo));
}
int log_syntax_internal(
@@ -1300,3 +1299,10 @@ void log_set_always_reopen_console(bool b) {
void log_set_open_when_needed(bool b) {
open_when_needed = b;
}
int log_emergency_level(void) {
/* Returns the log level to use for log_emergency() logging. We use LOG_EMERG only when we are PID 1, as only
* then the system of the whole system is obviously affected. */
return getpid_cached() == 1 ? LOG_EMERG : LOG_ERR;
}