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 formatting & consistency of logging messages #1023

Merged
merged 3 commits into from Sep 19, 2022

Conversation

ubruhin
Copy link
Member

@ubruhin ubruhin commented Sep 18, 2022

Remove "(:0)" in logging messages of release builds

In release builds, typically __FILE__ and __LINE__ are not set. But currently these values are still output on each logging line (i.e. on stderr), which lead to "(:0)". Since this is useless, let's hide this if file/line are unknown.

Improve formatting & consistency of logging messages

Documented and applied the following guidelines to ensure a consistent look of console output:

  • Logging messages shall not be translated, i.e. don't use tr() for them.
  • Output real sentences, starting with uppercase letter and ending with a period. Exceptions are allowed for something like "Invalid parameter: foo".
  • Try to output messages before the corresponding operation is performed. This helps to debug crashes since you see the last started operation. Use imperative language and end such messages with "...", for example "Save project...".
  • Output native file paths, not UNIX filepaths.

Example

[  INFO   ] LibrePCB 0.2.0-unstable (fec46c039)
[  INFO   ] Qt version: 5.15.5 (compiled against 5.15.5)
[  INFO   ] Resources directory: "/home/me/LibrePCB/share/librepcb"
[  INFO   ] Application settings: "/home/me/.config/LibrePCB/LibrePCB.ini"
[DEBUG-MSG] Network access manager thread started.
[DEBUG-MSG] Successfully loaded stroke font "/home/me/LibrePCB/share/librepcb/fontobene/newstroke.bene" with 2573 glyphs.
[DEBUG-MSG] Recently used workspace: "/home/me/LibrePCB-Workspace"
[DEBUG-MSG] Open workspace data directory "/home/me/LibrePCB-Workspace/data"...
[DEBUG-MSG] Load workspace settings...
[DEBUG-MSG] Successfully loaded workspace settings.
[DEBUG-MSG] Load workspace library database...
[DEBUG-MSG] Successfully loaded workspace library database.
[DEBUG-MSG] Successfully opened workspace.
[DEBUG-MSG] Workspace library scanner thread started.
[DEBUG-MSG] Start workspace library scan in worker thread...
[DEBUG-MSG] Workspace libraries indexed: 42 libraries in 18 ms.
[DEBUG-MSG] Open project "/home/me/LibrePCB-Workspace/projects/can2usb/can2usb.lpp"...
[DEBUG-MSG] Found stroke font: "newstroke.bene"
[DEBUG-MSG] Start loading stroke font  "/home/me/LibrePCB-Workspace/projects/can2usb/resources/fontobene/newstroke.bene" in worker thread...
[DEBUG-MSG] Load project metadata...
[DEBUG-MSG] Successfully loaded project metadata.
[DEBUG-MSG] Load project settings...
[DEBUG-MSG] Successfully loaded project settings.
[DEBUG-MSG] Load project library...
[DEBUG-MSG] Successfully loaded 17 symbols.
[DEBUG-MSG] Successfully loaded 14 packages.
[DEBUG-MSG] Successfully loaded 17 components.
[DEBUG-MSG] Successfully loaded 16 devices.
[DEBUG-MSG] Successfully loaded project library.
[DEBUG-MSG] Load circuit...
[DEBUG-MSG] Successfully loaded circuit.
[DEBUG-MSG] Successfully loaded 1 schematics.
[DEBUG-MSG] Successfully loaded stroke font "/home/me/LibrePCB-Workspace/projects/can2usb/resources/fontobene/newstroke.bene" with 2573 glyphs.
[DEBUG-MSG] Successfully loaded 1 boards.
[DEBUG-MSG] Successfully loaded project.
[DEBUG-MSG] Save project...
[DEBUG-MSG] Save project files to transactional file system...
[DEBUG-MSG] Successfully saved project.
[DEBUG-MSG] Closed project "/home/me/LibrePCB-Workspace/projects/can2usb/can2usb.lpp".
[DEBUG-MSG] Network access manager thread stopped.
[DEBUG-MSG] Workspace library scan aborted after 4706 ms.
[DEBUG-MSG] Workspace library scanner thread stopped.
[DEBUG-MSG] Exit application with code 0.

In release builds, typically `__FILE__` and `__LINE__` are not set.
But currently these values are still output on each logging line
(i.e. on stderr), which lead to "(:0)". Since this is useless, let's
hide this if file/line are unknown.
@ubruhin ubruhin added this to the 0.1.7 milestone Sep 18, 2022
@ubruhin ubruhin self-assigned this Sep 18, 2022
@ubruhin ubruhin merged commit 951ecd9 into master Sep 19, 2022
@ubruhin ubruhin deleted the consistent-log-messages branch September 19, 2022 09:39
ubruhin added a commit that referenced this pull request Sep 26, 2022
Improve formatting & consistency of logging messages

(cherry picked from commit 951ecd9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

1 participant