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

fix: Bad log spacing depending on the FORMAT and COLORS options used #4631

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

somethingSTRANGE
Copy link

@somethingSTRANGE somethingSTRANGE commented May 7, 2024

fixes: #4630

Previously, when colors were enabled, the log message always had a single space padded to the left, otherwise a single space was always padded to the right. This padding of the full log message seemed to be entirely unnecessary. Also, there was no explicit space set to appear between the timestamp and the log message, although when colors were enabled, the padding mentioned above would include a space, but only in that case.

Now, there's always a space between the timestamp and the log message, and there are no unnecessary spaces inserted at the beginning or end of the log message. I tested locally with all four combinations of format: pretty, format: pretty-timestamped, colors: false, and colors: true, and I believe the spacing now appears correct.

format: pretty with colors: false or colors: true:

info --- config file  - /var/lib/verdaccio/.config/verdaccio/config.yaml
info --- using htpasswd file: /var/lib/verdaccio/.config/verdaccio/htpasswd
info --- plugin successfully loaded: verdaccio-htpasswd
info --- plugin successfully loaded: verdaccio-audit
warn --- http address - http://127.0.0.1:4873/ - verdaccio/5.30.3

format: pretty-timestamped with colors: false or colors: true:

[2024-05-07 05:47:46] info --- config file  - /var/lib/verdaccio/.config/verdaccio/config.yaml
[2024-05-07 05:47:46] info --- using htpasswd file: /var/lib/verdaccio/.config/verdaccio/htpasswd
[2024-05-07 05:47:46] info --- plugin successfully loaded: verdaccio-htpasswd
[2024-05-07 05:47:46] info --- plugin successfully loaded: verdaccio-audit
[2024-05-07 05:47:46] warn --- http address - http://127.0.0.1:4873/ - verdaccio/5.30.3

fixes: verdaccio#4630

inserted a space between the timestamp and the message when logging timestamped messages.
fixes: verdaccio#4630

removed padding of an unnecessary space (at the start or end of the log string, depending on whether colors are enabled).
@somethingSTRANGE
Copy link
Author

Lint Error:
Error: 6:39 error 'padLeft' is defined but never used @typescript-eslint/no-unused-vars
/home/runner/work/verdaccio/verdaccio/packages/logger/logger-prettify/src/formatter.ts

'padLeft' is still defined but never used elsewhere in code. It was only used once in formatter.ts, but that use was removed with commit 6f81014.

Should the entire 'padLeft' function and all references to it (test, exports, etc.) be removed?

@mbtools
Copy link
Collaborator

mbtools commented May 11, 2024

Remove padLeft completely. We can always add it back later if necessary.

Also include a changeset, please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad log spacing depending on the FORMAT and COLORS options used
2 participants