]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Remove info() and die()
authorJohan Malm <jgm323@gmail.com>
Thu, 22 Jul 2021 20:30:17 +0000 (21:30 +0100)
committerJohan Malm <jgm323@gmail.com>
Thu, 22 Jul 2021 20:30:17 +0000 (21:30 +0100)
include/common/log.h
src/common/dir.c
src/common/log.c
src/config/rcxml.c
src/config/session.c
src/main.c
src/menu/menu.c
src/output.c
src/seat.c
src/server.c
src/theme.c

index e3beb8cb935113bc130f92e71f8fd7ce5344069e..81ece2a77a72d85aeaac693a6d5a2569cc83066d 100644 (file)
@@ -1,19 +1,9 @@
 #ifndef __LABWC_LOG_H
 #define __LABWC_LOG_H
 
-/**
- * info - print info message
- */
-void info(const char *msg, ...);
-
 /**
  * warn - print warning
  */
 void warn(const char *err, ...);
 
-/**
- * die - print fatal message and exit()
- */
-void die(const char *err, ...);
-
 #endif /* __LABWC_LOG_H */
index c3a7f09ee617003a840069be22dbc51afc2e5d0c..82889af2d0dfd73d728488277d6c480807a3f203 100644 (file)
@@ -85,7 +85,7 @@ find_dir(struct ctx *ctx)
                        /* handle /etc/xdg... */
                        ctx->build_path_fn(ctx, NULL, d.path);
                        if (debug) {
-                               info("%s", ctx->buf);
+                               fprintf(stderr, "%s\n", ctx->buf);
                        }
                        if (isdir(ctx->buf)) {
                                return ctx->buf;
@@ -100,7 +100,7 @@ find_dir(struct ctx *ctx)
                        for (gchar **p = prefixes; *p; p++) {
                                ctx->build_path_fn(ctx, *p, d.path);
                                if (debug) {
-                                       info("%s", ctx->buf);
+                                       fprintf(stderr, "%s\n", ctx->buf);
                                }
                                if (isdir(ctx->buf)) {
                                        g_strfreev(prefixes);
index 8e597db197516aa87d190a8f4729b04089f47c77..2049e0f3d25485b024cd755a256e1519a0c1f75d 100644 (file)
@@ -3,17 +3,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-void
-info(const char *msg, ...)
-{
-       va_list params;
-       fprintf(stderr, "[labwc] info: ");
-       va_start(params, msg);
-       vfprintf(stderr, msg, params);
-       va_end(params);
-       fprintf(stderr, "\n");
-}
-
 void
 warn(const char *err, ...)
 {
@@ -25,14 +14,3 @@ warn(const char *err, ...)
        fprintf(stderr, "\n");
 }
 
-void
-die(const char *err, ...)
-{
-       va_list params;
-       fprintf(stderr, "[labwc] fatal: ");
-       va_start(params, err);
-       vfprintf(stderr, err, params);
-       va_end(params);
-       fprintf(stderr, "\n");
-       exit(EXIT_FAILURE);
-}
index dd92f702973e1689120d6005dc2bc2bc3cfc2fad..791785017afae409cc578935d36163c483667781 100644 (file)
@@ -10,7 +10,7 @@
 #include <strings.h>
 #include <unistd.h>
 #include <wayland-server-core.h>
-
+#include <wlr/util/log.h>
 #include "common/dir.h"
 #include "common/log.h"
 #include "common/nodename.h"
@@ -273,7 +273,7 @@ static void
 post_processing(void)
 {
        if (!wl_list_length(&rc.keybinds)) {
-               info("load default key bindings");
+               wlr_log(WLR_INFO, "load default key bindings");
                bind("A-Escape", "Exit", NULL);
                bind("A-Tab", "NextWindow", NULL);
                bind("A-F3", "Execute", "bemenu-run");
@@ -323,7 +323,7 @@ rcxml_read(const char *filename)
                find_config_file(rcxml, sizeof(rcxml), filename);
        }
        if (rcxml[0] == '\0') {
-               info("cannot find rc.xml config file; using defaults");
+               wlr_log(WLR_INFO, "cannot find rc.xml config file");
                goto no_config;
        }
 
@@ -333,7 +333,7 @@ rcxml_read(const char *filename)
                warn("cannot read (%s)", rcxml);
                goto no_config;
        }
-       info("read config file (%s)", rcxml);
+       wlr_log(WLR_INFO, "read config file %s", rcxml);
        buf_init(&b);
        while (getline(&line, &len, stream) != -1) {
                char *p = strrchr(line, '\n');
index b046bece61c42fea3d8c2cb0c6b4593f26146255..695a79e10a888315d6e81a78dea3ac3278930515 100644 (file)
@@ -5,6 +5,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <wlr/util/log.h>
 #include "common/dir.h"
 #include "common/log.h"
 #include "common/spawn.h"
@@ -52,7 +53,7 @@ read_environment_file(const char *filename)
        if (!stream) {
                return;
        }
-       info("read environment file (%s)", filename);
+       wlr_log(WLR_INFO, "read environment file %s", filename);
        while (getline(&line, &len, stream) != -1) {
                char *p = strrchr(line, '\n');
                if (p) {
@@ -101,7 +102,7 @@ session_autostart_init(void)
                warn("no autostart file");
                goto out;
        }
-       info("run autostart file (%s)", autostart);
+       wlr_log(WLR_INFO, "run autostart file %s", autostart);
        int len = strlen(autostart) + 4;
        char *cmd = calloc(len, 1);
        strcat(cmd, "sh ");
index 23a13d9139a24f0b4f9c1e36628cc8c7e787107d..6f8092ad3ff5562f5395c613a3c1bc0c208d0789 100644 (file)
@@ -59,7 +59,8 @@ main(int argc, char *argv[])
        rcxml_read(config_file);
 
        if (!getenv("XDG_RUNTIME_DIR")) {
-               die("XDG_RUNTIME_DIR is unset");
+               wlr_log(WLR_ERROR, "XDG_RUNTIME_DIR is unset");
+               exit(EXIT_FAILURE);
        }
 
        struct server server = { 0 };
index 0709cf6820e186ca7382249105d88ff8d1cccb3e..81d4c76b7eed0a561c676baf08d5647c47699b4f 100644 (file)
@@ -10,6 +10,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <strings.h>
+#include <wlr/util/log.h>
 #include "common/buf.h"
 #include "common/dir.h"
 #include "common/font.h"
@@ -209,7 +210,7 @@ parse_xml(const char *filename, struct menu *menu)
                warn("cannot read (%s)", menuxml);
                return;
        }
-       info("read menu file (%s)", menuxml);
+       wlr_log(WLR_INFO, "read menu file %s", menuxml);
        buf_init(&b);
        while (getline(&line, &len, stream) != -1) {
                char *p = strrchr(line, '\n');
index 43036aa449fb9349f537a6795465680bb069ff94..a3c1e9308ebbab5d6e37b31a702f1e7775019a90 100644 (file)
@@ -834,7 +834,7 @@ new_output_notify(struct wl_listener *listener, void *data)
         */
 
        if (getenv("LABWC_ADAPTIVE_SYNC")) {
-               info("Set %s adaptive sync to 'true'", wlr_output->name);
+               wlr_log(WLR_INFO, "enable adaptive sync on %s", wlr_output->name);
                wlr_output_enable_adaptive_sync(wlr_output, true);
        }
        wlr_output_layout_add_auto(server->output_layout, wlr_output);
index 8beef3dc85c7aab5034d5dd712f9df0428a2c705..e5a1dbec65abf304d7f0e59c402d7dadcefd0ba1 100644 (file)
@@ -31,7 +31,7 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
        if (libinput_device_config_tap_get_finger_count(libinput_dev) <= 0) {
                return;
        }
-       info("tap enabled for libinput device");
+       wlr_log(WLR_INFO, "tap enabled");
        libinput_device_config_tap_set_enabled(libinput_dev,
                LIBINPUT_CONFIG_TAP_ENABLED);
 }
index 036ee7a62cc824b43b3e71c0d80bcadc48e485ab..a9d2392742092e3328db8b047807a56d887b2d17 100644 (file)
@@ -24,13 +24,14 @@ static struct server *g_server;
 static void
 reload_config_and_theme(void)
 {
+       damage_all_outputs(g_server);
+
        /* TODO: use rc.config_path */
        rcxml_finish();
        rcxml_read(NULL);
        theme_finish(g_server->theme);
        theme_init(g_server->theme, g_server->renderer, rc.theme_name);
        menu_reconfigure(g_server, g_server->rootmenu);
-       damage_all_outputs(g_server);
 }
 
 static int
@@ -54,14 +55,17 @@ drop_permissions(void)
 {
        if (getuid() != geteuid() || getgid() != getegid()) {
                if (setgid(getgid())) {
-                       die("unable to drop root group");
+                       wlr_log(WLR_ERROR, "unable to drop root group");
+                       exit(EXIT_FAILURE);
                }
                if (setuid(getuid())) {
-                       die("unable to drop root user");
+                       wlr_log(WLR_ERROR, "unable to drop root user");
+                       exit(EXIT_FAILURE);
                }
        }
        if (setgid(0) != -1 || setuid(0) != -1) {
-               die("unable to drop root");
+               wlr_log(WLR_ERROR, "unable to drop root");
+               exit(EXIT_FAILURE);
        }
 }
 
index f80e24483f78277a50f92bae60dffd9f627ecaff..ca760ed51ee20814ed07363e37eaa4d54fc60fe2 100644 (file)
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <wlr/util/box.h>
+#include <wlr/util/log.h>
 
 #include "common/dir.h"
 #include "common/font.h"
@@ -191,12 +192,11 @@ theme_read(struct theme *theme, const char *theme_name)
        }
        if (!stream) {
                if (theme_name) {
-                       info("cannot find theme (%s), using built-in",
-                            theme_name);
+                       wlr_log(WLR_INFO, "cannot find theme %s", theme_name);
                }
                return;
        }
-       info("read themerc (%s)", themerc);
+       wlr_log(WLR_INFO, "read theme %s", themerc);
        while (getline(&line, &len, stream) != -1) {
                char *p = strrchr(line, '\n');
                if (p) {