]> git.mdlowis.com Git - proto/labwc.git/commitdiff
desktop-entry: demote libsfdo error-logging
authorJohan Malm <jgm323@gmail.com>
Fri, 27 Dec 2024 22:19:35 +0000 (22:19 +0000)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 30 Dec 2024 22:39:02 +0000 (23:39 +0100)
...to WLR_INFO to avoid logging issues with .desktop files as errors, for
example:

    [sfdo-desktop] 1:1: Name is unset
    [sfdo-desktop] Failed to load /usr/share/applications/lxqt-panel.desktop
    [sfdo-desktop] 1:1: Exec is unset while DBusActivatable is unset or false
    [sfdo-desktop] Failed to load /usr/share/applications/qemu.desktop

Also make libsfdo debug/info logging depend on environment variable
LABWC_DEBUG_LIBSFDO being set to avoid disproportionately verbose logging
by default for one particular sub-system.

Add an 'ENVIRONMENT VARIABLES' section to labwc(1) to describe the above
as well as other hitherto undocumented env vars with prefix LABWC_DEBUG_.

docs/labwc.1.scd
src/desktop-entry.c

index 2bb66572889d3ad5f00a2b12634a4c7655f44a1a..4e64391874efb45f520bd26f5d590b7d284b06a4 100644 (file)
@@ -39,7 +39,8 @@ the `--exit` and `--reconfigure` options use.
        Specify a config directory
 
 *-d, --debug*
-       Enable full logging, including debug information
+       Enable full logging, including debug information. See *ENVIRONMENT
+       VARIABLES* section below for further options.
 
 *-e, --exit*
        Exit the compositor by sending SIGTERM to `$LABWC_PID`
@@ -117,6 +118,32 @@ this is accomplished by setting the session variables to empty strings. For
 systemd, the command `systemctl --user unset-environment` will be invoked to
 actually remove the variables from the activation environment.
 
+# ENVIRONMENT VARIABLES
+
+Set the environment variables listed below to enable specific debug options.
+This can be done in either the *environment* file or on the command line, for
+example: *LABWC_DEBUG_FOO=1 labwc*.
+
+*LABWC_DEBUG_LIBSFDO*
+       Enable debug and info logging for libsfdo, for example for parsing of
+       .desktop files and searching for icons. Note that libsfdo error logging
+       is always enabled regardless of this environment variable but will only
+       be shown with the *-V|--version* option.
+
+*LABWC_DEBUG_DIR_CONFIG_AND_THEME*
+       Increase logging of paths for config files (for example rc.xml,
+       autostart, environment and menu.xml) as well as titlebar buttons.
+
+*LABWC_DEBUG_CONFIG_NODENAMES*++
+*LABWC_DEBUG_MENU_NODENAMES*
+       Enable logging of all nodenames (for example *policy.placement: Cascade*
+       for *<placement><policy>Cascade</policy></placement>*) for config and
+       menu files respectively.
+
+*LABWC_DEBUG_KEY_STATE*
+       Enable logging of press and release events for bound keys (generally
+       key-combinations like *Ctrl-Alt-t*)
+
 # SEE ALSO
 
 labwc-actions(5), labwc-config(5), labwc-menu(5), labwc-theme(5)
index b4bc9d943990b4a1f54c43b762b7d9f2108632c4..1d84fd4f5106146ef521accdc9858b55673f58b8 100644 (file)
@@ -2,6 +2,7 @@
 #include <sfdo-desktop.h>
 #include <sfdo-icon.h>
 #include <sfdo-basedir.h>
+#include <stdlib.h>
 #include <string.h>
 #include <strings.h>
 #include <wlr/util/log.h>
@@ -13,6 +14,8 @@
 
 #include "labwc.h"
 
+static const char *debug_libsfdo;
+
 struct sfdo {
        struct sfdo_desktop_ctx *desktop_ctx;
        struct sfdo_icon_ctx *icon_ctx;
@@ -23,6 +26,23 @@ struct sfdo {
 static void
 log_handler(enum sfdo_log_level level, const char *fmt, va_list args, void *tag)
 {
+       /*
+        * libsfdo info/debug logging is only provided when LABWC_DEBUG_LIBSFDO
+        * is set to avoid disproportionately verbose logging by default for one
+        * particularly sub-system.
+        */
+       if (!debug_libsfdo && level > SFDO_LOG_LEVEL_ERROR) {
+               return;
+       }
+
+       /*
+        * To avoid logging issues with .desktop files as errors, all libsfdo
+        * error-logging is demoted to info level.
+        */
+       if (level == SFDO_LOG_LEVEL_ERROR) {
+               level = SFDO_LOG_LEVEL_INFO;
+       }
+
        /* add a prefix if the format length is reasonable */
        char buf[256];
        if (snprintf(buf, sizeof(buf), "[%s] %s", (const char *)tag, fmt)
@@ -38,6 +58,8 @@ desktop_entry_init(struct server *server)
 {
        struct sfdo *sfdo = znew(*sfdo);
 
+       debug_libsfdo = getenv("LABWC_DEBUG_LIBSFDO");
+
        struct sfdo_basedir_ctx *basedir_ctx = sfdo_basedir_ctx_create();
        if (!basedir_ctx) {
                goto err_basedir_ctx;