diff --git a/src/say.c b/src/say.c index a6cf25e5fe143c3b936e9cbc4af57a0e36ca8e71..44e1d22a81c423bdc155125da24ad19730dd6887 100644 --- a/src/say.c +++ b/src/say.c @@ -52,8 +52,7 @@ int log_level = S_INFO; static const char logger_syntax_reminder[] = "expecting a file name or a prefix, such as '|', 'pipe:', 'syslog:'"; -static bool booting = true; -static enum say_logger_type logger_type = SAY_LOGGER_STDERR; +static enum say_logger_type logger_type = SAY_LOGGER_BOOT; static bool logger_background = true; static int logger_nonblock; @@ -367,6 +366,8 @@ say_logger_init(const char *init_str, int level, int nonblock, int background) fcntl(log_fd, F_SETFL, flags | O_NONBLOCK) < 0) say_syserror("fcntl, fd=%i", log_fd); } + } else { + logger_type = SAY_LOGGER_STDERR; } if (background) { @@ -384,7 +385,6 @@ say_logger_init(const char *init_str, int level, int nonblock, int background) dup2(log_fd, STDOUT_FILENO); } } - booting = false; } void @@ -529,7 +529,7 @@ vsay(int level, const char *filename, int line, const char *error, filename = f + 1; int total; - if (booting) { + if (logger_type == SAY_LOGGER_BOOT) { total = say_format_boot(buf, sizeof(buf), error, format, ap); assert(total >= 0); (void) write(STDERR_FILENO, buf, total); diff --git a/src/say.h b/src/say.h index fd765b1ac613be5ff613738e7684525da46b280a..351ff97fad081e1b995634d9e62a8508159e15fa 100644 --- a/src/say.h +++ b/src/say.h @@ -148,6 +148,7 @@ say_check_init_str(const char *str, char **error); /* internals, for unit testing */ enum say_logger_type { + SAY_LOGGER_BOOT, SAY_LOGGER_STDERR, SAY_LOGGER_FILE, SAY_LOGGER_PIPE, diff --git a/test/unit/say.c b/test/unit/say.c index 237304cdb372f8bdc68654a2d837765f317835aa..762b0ead5add9b153e6be8e2f7de4bf4c9dc011f 100644 --- a/test/unit/say.c +++ b/test/unit/say.c @@ -10,6 +10,8 @@ parse_logger_type(const char *input) if (rc == 0) switch (type) { + case SAY_LOGGER_BOOT: + note("type: boot"); break; case SAY_LOGGER_STDERR: note("type: stderr"); break; case SAY_LOGGER_FILE: