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 <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-11-10 19:12:16 +00:00
parent 87e4e10f15
commit 71ac1bfd30
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 10 additions and 1 deletions

View File

@ -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;
}