Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logging and termination #1899

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

Caellian
Copy link
Collaborator

@Caellian Caellian commented May 4, 2024

This PR tackles following issues:

  • Conky almost always exists with exit (on CRIT_ERR) and the same semantics are used for user error, system error and developer error (bugs).
    • unlike abort, exit doesn't produce a core dump which adds extra steps to figuring out what the problems are.
  • People start conky through all kinds of different means and some don't make the logs readily available.
    • This makes it very difficult to debug some issues because logs can't be provided.
  • There's too few supported log levels = non-critical error messages look the same as info.
  • C++ std::terminate() isn't used often enough, even though it's safer than abort (concurrency).
    • std::terminate() allows us to dump stack traces on errors.

Changes

  • Rewrote logging to explicitly handle different log levels.
    • Old log macros/functions are #defined to use the new ones.
  • Added nicer looking error printing:
[2024-05-04 01:51:49.828][DEBUG][src/conky.cc:1962]: reading contents from config file '~/.config/conky/conky.conf'
[2024-05-04 01:51:49.828][DEBUG][src/x11.cc:236]: enter init_x11()
[2024-05-04 01:51:49.830][DEBUG][src/x11.cc:358]: Fixed xinerama area to: 0 0 1920 1080
[2024-05-04 01:51:49.830][DEBUG][src/x11.cc:280]: leave init_x11()
[2024-05-04 01:51:49.830][DEBUG][src/x11.cc:476]: enter x11_init_window()
[2024-05-04 01:51:49.830][DEBUG][src/x11.cc:358]: Fixed xinerama area to: 0 0 1920 1080
[2024-05-04 01:51:49.830][INFO][src/x11.cc:379]: desktop window (0x1600016) is subwindow of root window (0x1c7)
[2024-05-04 01:51:49.830][INFO][src/x11.cc:558]: window type - override
[2024-05-04 01:51:49.830][INFO][src/x11.cc:783]: drawing to created window (0x5400001)
[2024-05-04 01:51:49.832][DEBUG][src/x11.cc:891]: leave x11_init_window()
[2024-05-04 01:51:49.833][INFO][src/x11-settings.cc:67]: drawing to double buffer
[2024-05-04 01:51:49.833][INFO][src/setting.cc:62]: Unknown setting 'out_to_wayland'
[2024-05-04 01:51:49.833][TRACE][src/core.cc:2108]: no templates to replace
[2024-05-04 01:51:49.833][WARNING][src/core.cc:2037]: unknown variable '$wireless_ap'
[2024-05-04 01:51:49.833][WARNING][src/core.cc:2037]: unknown variable '$wireless_ap'
[2024-05-04 01:51:49.833][WARNING][src/core.cc:2037]: unknown variable '$wireless_bitrate'
[2024-05-04 01:51:49.833][WARNING][src/core.cc:2037]: unknown variable '$wireless_channel'
[2024-05-04 01:51:49.833][WARNING][src/core.cc:2037]: unknown variable '$wireless_essid'
[2024-05-04 01:51:49.833][WARNING][src/core.cc:2037]: unknown variable '$wireless_freq'
[2024-05-04 01:51:49.833][WARNING][src/core.cc:2037]: unknown variable '$wireless_link_qual'
[2024-05-04 01:51:49.833][WARNING][src/core.cc:2037]: unknown variable '$wireless_link_qual_max'
[2024-05-04 01:51:49.833][WARNING][src/core.cc:2037]: unknown variable '$wireless_mode'
[2024-05-04 01:51:49.833][INFO][src/display-output.cc:39]: HTTP display output disabled. Enable by recompiling with 'BUILD_HTTP' flag enabled.
[2024-05-04 01:51:49.833][INFO][src/display-output.cc:39]: Wayland display output disabled. Enable by recompiling with 'BUILD_WAYLAND' flag enabled.
[2024-05-04 01:51:49.833][TRACE][src/display-output.cc:91]: console output display found.
[2024-05-04 01:51:49.833][TRACE][src/display-output.cc:91]: ncurses output display found.
[2024-05-04 01:51:49.833][TRACE][src/display-output.cc:91]: file output display found.
[2024-05-04 01:51:49.833][TRACE][src/display-output.cc:91]: x11 output display found.
[2024-05-04 01:51:49.833][TRACE][src/display-output.cc:101]: Testing display output 'x11'... 
[2024-05-04 01:51:49.833][TRACE][src/display-x11.cc:230]: Display output 'x11' enabled in config.
[2024-05-04 01:51:49.833][TRACE][src/display-output.cc:103]: Detected display output 'x11'... 
[2024-05-04 01:51:49.833][TRACE][src/fonts.cc:64]: setting up fonts
[2024-05-04 01:51:49.833][TRACE][src/fonts.cc:84]: loading fonts
[2024-05-04 01:51:49.850][TRACE][src/fonts.cc:64]: setting up fonts
[2024-05-04 01:51:49.850][TRACE][src/fonts.cc:64]: setting up fonts
  • Reduced number of generated functions per log call.
  • Added use of POSIX syslog.h, which forwards logs to system journal.
    • Fallback to /tmp/conky.log file output.
  • Removed DEBUG define to avoid conflicts
    • Compiler defines NDEBUG (inverse), so this also simplifies build configuration.
    • Not used frequently.
  • Add support for printing stack traces on std::terminate().
    • We can tell by error messages what's wrong though. We really want abort handling. Regular stack trace printing with abort is very inconvenient.
  • Correct some previous CRIT_ERR and NORM_ERR calls.

Signed-off-by: Tin Švagelj <[email protected]>
@github-actions github-actions bot added sources PR modifies project sources dependencies adds or removes dependencies, or suggests alternatives build system related to build system (CMake) and/or building process/assumptions os: macos related to MacOS labels May 4, 2024
Copy link

netlify bot commented May 4, 2024

Deploy Preview for conkyweb canceled.

Name Link
🔨 Latest commit 369136c
🔍 Latest deploy log https://app.netlify.com/sites/conkyweb/deploys/6695a8fc3113b40008a891ff

@Caellian Caellian force-pushed the dev/improve-termination branch 6 times, most recently from b8e1a35 to 499d15f Compare May 4, 2024 01:26
Signed-off-by: Tin Švagelj <[email protected]>
@Caellian Caellian force-pushed the dev/improve-termination branch from 499d15f to ac0fd42 Compare May 4, 2024 01:34
@Caellian Caellian added the feature suggest addition of new functionality that isn't currently supported in any way label May 4, 2024
This removes some checks and formatting from log statements

Signed-off-by: Tin Švagelj <[email protected]>
@github-actions github-actions bot added the nvidia related to Nvidia GPU information reporting label May 4, 2024
Not sure why it started with two nullptrs. Probably ancient code.

Signed-off-by: Tin Švagelj <[email protected]>
@Caellian Caellian force-pushed the dev/improve-termination branch from 7d896cc to 33716cb Compare May 4, 2024 02:58
This makes logging.h/cc not have to know about `clean_up()` because
global handler calls it.
It also allows them to be caught.

Signed-off-by: Tin Švagelj <[email protected]>
@Caellian Caellian marked this pull request as draft May 4, 2024 13:29
@github-actions github-actions bot added lua related to Lua integration in conky cairo related to cairo (2D graphics library) labels May 4, 2024
@Caellian Caellian force-pushed the dev/improve-termination branch from 4828216 to eeccc71 Compare May 4, 2024 14:46
Separate logger from logging header.

Signed-off-by: Tin Švagelj <[email protected]>
@Caellian Caellian force-pushed the dev/improve-termination branch 5 times, most recently from 548351b to 457ce1b Compare May 4, 2024 15:03
Signed-off-by: Tin Švagelj <[email protected]>
@Caellian Caellian force-pushed the dev/improve-termination branch from 457ce1b to d467576 Compare May 4, 2024 15:11
Fix runtime crash

Signed-off-by: Tin Švagelj <[email protected]>
@Caellian Caellian marked this pull request as ready for review May 4, 2024 16:45
Copy link
Owner

@brndnmtthws brndnmtthws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Massive improvement, thanks!

Caellian added 3 commits May 8, 2024 02:26
Defined a new format for variable/command related logs so it's clearer
what they relate to.

Signed-off-by: Tin Švagelj <[email protected]>
- Introduce very simple sink implementation for better formatting specialization.
- Add colors.

Signed-off-by: Tin Švagelj <[email protected]>
@github-actions github-actions bot added cpu related to CPU stats or system process reporting display: x11 related to X11 backend display: wayland related to Wayland backend rendering related to code that handles rendering, excluding the used graphics API display: file related to file backend display: http related to HTTP backend disk io related to disk I/O statistics text related to `conky.text` variables, their parsing or implementation power related to battery and power management code labels Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system related to build system (CMake) and/or building process/assumptions cairo related to cairo (2D graphics library) cpu related to CPU stats or system process reporting dependencies adds or removes dependencies, or suggests alternatives disk io related to disk I/O statistics display: file related to file backend display: http related to HTTP backend display: wayland related to Wayland backend display: x11 related to X11 backend feature suggest addition of new functionality that isn't currently supported in any way lua related to Lua integration in conky nvidia related to Nvidia GPU information reporting os: macos related to MacOS power related to battery and power management code rendering related to code that handles rendering, excluding the used graphics API sources PR modifies project sources text related to `conky.text` variables, their parsing or implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants