From 71ac1bfd30ce20019addc123eef4b8085d212e4f Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 10 Nov 2019 19:12:16 +0000 Subject: [PATCH] core: use the logging system all the way Add a log handler early so we don't need to use fprintf for early logs. Signed-off-by: Yuxuan Shui --- src/picom.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/picom.c b/src/picom.c index 51031c4..6c4c644 100644 --- a/src/picom.c +++ b/src/picom.c @@ -2294,8 +2294,17 @@ int main(int argc, char **argv) { // Set locale so window names with special characters are interpreted // correctly setlocale(LC_ALL, ""); + + // Initialize logging system for early logging log_init_tls(); + { + auto stderr_logger = stderr_logger_new(); + if (stderr_logger) { + log_add_target_tls(stderr_logger); + } + } + int exit_code; char *config_file = NULL; bool all_xerrors = false, need_fork = false; @@ -2340,7 +2349,7 @@ int main(int argc, char **argv) { do { Display *dpy = XOpenDisplay(NULL); if (!dpy) { - fprintf(stderr, "Can't open display."); + log_fatal("Can't open display."); ret_code = 1; break; }