Skip to content

Improved logging messages #193

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Video-Nomad
Copy link
Contributor

Just a proposition for a more detailed logging in file and in the console.

In the console we are adding colored output based on the severity and time signature.
Debug will stay the default color, info is green, warning is yellow, error is red and critical has a red background.
Actual colors will depend on the terminal settings.

Windows Terminal:
image

In the log file we are adding more info: thread name and logger name next to the file name:

2025-04-04 14:03:02,404 [MainThread] [DEBUG] [root/main.py:70]: Debug message!
2025-04-04 14:03:02,404 [MainThread] [INFO] [root/main.py:71]: Info message!
2025-04-04 14:03:02,404 [MainThread] [WARNING] [root/main.py:72]: Warning message!
2025-04-04 14:03:02,404 [MainThread] [ERROR] [root/main.py:73]: Error message!
2025-04-04 14:03:02,404 [MainThread] [CRITICAL] [root/main.py:74]: Critical message!
2025-04-04 14:03:02,421 [MainThread] [INFO] [root/main.py:25]: Debug mode enabled.
2025-04-04 14:03:02,550 [MainThread] [DEBUG] [glazewm_client/client.py:79]: Connecting to PyQt6.QtCore.QUrl('ws://localhost:6123')...
2025-04-04 14:03:02,551 [MainThread] [DEBUG] [glazewm_client/client.py:92]: WebSocket state changed: SocketState.ConnectingState
2025-04-04 14:03:02,667 [MainThread] [DEBUG] [core.utils.win32.media/media.py:107]: MediaCallback: _on_current_session_changed
2025-04-04 14:03:02,760 [MainThread] [DEBUG] [comtypes/__init__.py:143]: CoInitializeEx(None, 2)
2025-04-04 14:03:02,869 [Thread-1 (_get_weather_data)] [INFO] [root/weather.py:369]: Fetched new weather data at 2025-04-04 14:03:02.869613
2025-04-04 14:03:02,901 [MainThread] [DEBUG] [tzlocal/win32.py:58]: Looking up time zone info from registry
2025-04-04 14:03:02,959 [MainThread] [INFO] [root/app_bar.py:103]: Bar Created on Screen: XXXXXXXX [Bar Height: 20px, DPI Scale: 1.0, Scale Screen: True, Screen Geometry: X: 0, Y: 0, Screen Width: 2560, Screen Height: 1440]
2025-04-04 14:03:03,380 [MainThread] [DEBUG] [glazewm_client/client.py:79]: Connecting to PyQt6.QtCore.QUrl('ws://localhost:6123')...
2025-04-04 14:03:03,457 [Thread-2 (_get_weather_data)] [INFO] [root/weather.py:369]: Fetched new weather data at 2025-04-04 14:03:03.457457
2025-04-04 14:03:03,467 [MainThread] [INFO] [root/app_bar.py:103]: Bar Created on Screen: XXXXXXXX [Bar Height: 20px, DPI Scale: 1.0, Scale Screen: True, Screen Geometry: X: -2560, Y: 0, Screen Width: 2560, Screen Height: 1440]
2025-04-04 14:03:03,614 [MainThread] [INFO] [root/watcher.py:39]: Created file watcher for path C:\Users\XXXXXXXX\.config\yasb
2025-04-04 14:03:03,616 [MainThread] [DEBUG] [qasync._windows._EventPoller/_windows.py:213]: Starting (proactor: <_IocpProactor overlapped#=0 result#=0>)...
2025-04-04 14:03:03,617 [Dummy-5] [DEBUG] [qasync._windows._EventWorker/_windows.py:192]: Thread started
2025-04-04 14:03:03,618 [MainThread] [DEBUG] [core.utils.win32.media/media.py:107]: MediaCallback: _on_current_session_changed
2025-04-04 14:03:03,618 [TrayMonitorThread] [DEBUG] [systray_widget/systray.py:65]: TrayMonitorThread started
2025-04-04 14:03:03,621 [MainThread] [DEBUG] [core.utils.win32.media/media.py:107]: MediaCallback: _on_current_session_changed
2025-04-04 14:03:03,819 [MainThread] [DEBUG] [systray_widget/tray_monitor.py:188]: Registered for TaskbarCreated message: 49249
2025-04-04 14:03:03,828 [MainThread] [DEBUG] [systray_widget/tray_monitor.py:188]: Registered for TaskbarCreated message: 49249
2025-04-04 14:03:04,953 [MainThread] [DEBUG] [systray_widget/systray.py:412]: Re-sorting widgets
2025-04-04 14:03:04,953 [MainThread] [DEBUG] [systray_widget/systray.py:434]: Updating current state

Since we are managing quite a few threads naming them appropriately will help with the logging as well in the future.

@Video-Nomad Video-Nomad force-pushed the feat/improved-logging-messages branch from 23af61a to eb77157 Compare April 4, 2025 12:23
@Video-Nomad Video-Nomad changed the title feat(log): improved logging messages Improved logging messages Apr 4, 2025
@Video-Nomad Video-Nomad marked this pull request as draft April 4, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant