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 8 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 <tin.svagelj@live.com>
@github-actions github-actions bot added sources PR modifies project sources dependencies Issue or PR that affects dependencies build system Issues and PRs related to build system (CMake) and process macos Issue or PR related to MacOS labels May 4, 2024
Copy link

netlify bot commented May 4, 2024

Deploy Preview for conkyweb canceled.

Name Link
🔨 Latest commit f00d858
🔍 Latest deploy log https://app.netlify.com/sites/conkyweb/deploys/663653cacbbe8b0008f1d9c9

@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 <tin.svagelj@live.com>
@Caellian Caellian added the feature New feature PR or issue label May 4, 2024
This removes some checks and formatting from log statements

Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
@github-actions github-actions bot added the nvidia Issue or PR related to nvidia cards label May 4, 2024
Not sure why it started with two nullptrs. Probably ancient code.

Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
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 <tin.svagelj@live.com>
@Caellian Caellian marked this pull request as draft May 4, 2024 13:29
@github-actions github-actions bot added lua Issue or PR related to Lua code cairo Issue or PR related to cairo labels May 4, 2024
Separate logger from logging header.

Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
@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 <tin.svagelj@live.com>
Fix runtime crash

Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system Issues and PRs related to build system (CMake) and process cairo Issue or PR related to cairo dependencies Issue or PR that affects dependencies feature New feature PR or issue lua Issue or PR related to Lua code macos Issue or PR related to MacOS nvidia Issue or PR related to nvidia cards sources PR modifies project sources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants