i3 - improved tiling WM


Do not use ELOG while logwalk is not initialized

Patch status: merged

Patch by Baptiste Daroussin

To apply this patch, use:
curl http://cr.i3wm.org/patch/100/raw.patch | git am

b/src/log.c

13
@@ -81,11 +81,11 @@ static void store_log_markers(void) {
14
 void init_logging(void) {
15
     if (!errorfilename) {
16
         if (!(errorfilename = get_process_filename("errorlog")))
17
-            ELOG("Could not initialize errorlog\n");
18
+            fprintf(stderr, "Could not initialize errorlog\n");
19
         else {
20
             errorfile = fopen(errorfilename, "w");
21
             if (fcntl(fileno(errorfile), F_SETFD, FD_CLOEXEC)) {
22
-                ELOG("Could not set close-on-exec flag\n");
23
+                fprintf(stderr, "Could not set close-on-exec flag\n");
24
             }
25
         }
26
     }
27
@@ -110,14 +110,14 @@ void init_logging(void) {
28
         sasprintf(&shmlogname, "/i3-log-%d", getpid());
29
         logbuffer_shm = shm_open(shmlogname, O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
30
         if (logbuffer_shm == -1) {
31
-            ELOG("Could not shm_open SHM segment for the i3 log: %s\n", strerror(errno));
32
+            fprintf(stderr, "Could not shm_open SHM segment for the i3 log: %s\n", strerror(errno));
33
             return;
34
         }
35
 
36
         if (ftruncate(logbuffer_shm, logbuffer_size) == -1) {
37
             close(logbuffer_shm);
38
             shm_unlink("/i3-log-");
39
-            ELOG("Could not ftruncate SHM segment for the i3 log: %s\n", strerror(errno));
40
+            fprintf(stderr, "Could not ftruncate SHM segment for the i3 log: %s\n", strerror(errno));
41
             return;
42
         }
43
 
44
@@ -125,7 +125,7 @@ void init_logging(void) {
45
         if (logbuffer == MAP_FAILED) {
46
             close(logbuffer_shm);
47
             shm_unlink("/i3-log-");
48
-            ELOG("Could not mmap SHM segment for the i3 log: %s\n", strerror(errno));
49
+            fprintf(stderr, "Could not mmap SHM segment for the i3 log: %s\n", strerror(errno));
50
             logbuffer = NULL;
51
             return;
52
         }
53
@@ -138,7 +138,7 @@ void init_logging(void) {
54
         pthread_condattr_t cond_attr;
55
         pthread_condattr_init(&cond_attr);
56
         if (pthread_condattr_setpshared(&cond_attr, PTHREAD_PROCESS_SHARED) != 0)
57
-            ELOG("pthread_condattr_setpshared() failed, i3-dump-log -f will not work!\n");
58
+            fprintf(stderr, "pthread_condattr_setpshared() failed, i3-dump-log -f will not work!\n");
59
         pthread_cond_init(&(header->condvar), &cond_attr);
60
 
61
         logwalk = logbuffer + sizeof(i3_shmlog_header);