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

Bad log spacing depending on the FORMAT and COLORS options used #4630

Open
1 task done
somethingSTRANGE opened this issue May 6, 2024 · 0 comments · May be fixed by #4631
Open
1 task done

Bad log spacing depending on the FORMAT and COLORS options used #4630

somethingSTRANGE opened this issue May 6, 2024 · 0 comments · May be fixed by #4631

Comments

@somethingSTRANGE
Copy link

somethingSTRANGE commented May 6, 2024

Your Environment

  • verdaccio version: 5.30.3
  • node version [20.11.1, 20.12.2]:
  • package manager: [npm@10]
  • os: [linux]
  • platform: [npm]

Describe the bug

There are two minor issues with log spacing, depending on the format and colors options chosen.

  1. There's an extra single space character preceding the first ANSI color sequence at the beginning of the string (before "info" or "warn" in the following examples). This is most obvious with format: pretty, colors: true. There's also an extra space character at the end of each line when colors: false. I didn't notice this until I examined the code.

  2. There's a missing space character after the timestamp and before the actual log message. This is obvious with format: pretty-timestamped, colors: false.

As a result of these two issues, the above two option combinations produce logs with either extra unnecessary characters or characters that are mashed together making the log more difficult to read. However, if you were to only look at the format: pretty-timestamped, colors: true combination, things would appear to be correct, but that hides the underlying issues.

Here are the four relevant combinations for comparison:

format: pretty, colors: false:

Note the extra space at the end of each line.

info --- config file  - /home/greybornadmin/.config/verdaccio/config.yaml 
info --- using htpasswd file: /home/greybornadmin/.config/verdaccio/htpasswd 
info --- plugin successfully loaded: verdaccio-htpasswd 
info --- plugin successfully loaded: verdaccio-audit 
warn --- http address - http://0.0.0.0:4873/ - verdaccio/5.29.2 

format: pretty, colors: true:

Note the space at the start of each line.

 ←[36minfo ←[39m←[37m←[34m---←[37m config file  - ←[32m/home/greybornadmin/.config/verdaccio/config.yaml←[37m←[39m
 ←[36minfo ←[39m←[37m←[34m---←[37m using htpasswd file: ←[32m/home/greybornadmin/.config/verdaccio/htpasswd←[37m←[39m
 ←[36minfo ←[39m←[37m←[34m---←[37m plugin successfully loaded: ←[32mverdaccio←[37m-←[32mhtpasswd←[37m←[39m
 ←[36minfo ←[39m←[37m←[34m---←[37m plugin successfully loaded: ←[32mverdaccio←[37m-←[32maudit←[37m←[39m
 ←[33mwarn ←[39m←[37m←[34m---←[37m http address - ←[32mhttp://0.0.0.0:4873/←[37m - ←[32mverdaccio/5.29.2←[37m←[39m

format: pretty-timestamped, colors: false:

Note the missing space before "info" and "warn", but there is an extra space at the end of each line.

[2024-03-07 19:48:33]info --- config file  - /home/greybornadmin/.config/verdaccio/config.yaml 
[2024-03-07 19:48:33]info --- using htpasswd file: /home/greybornadmin/.config/verdaccio/htpasswd 
[2024-03-07 19:48:33]info --- plugin successfully loaded: verdaccio-htpasswd 
[2024-03-07 19:48:33]info --- plugin successfully loaded: verdaccio-audit 
[2024-03-07 19:48:33]warn --- http address - http://0.0.0.0:4873/ - verdaccio/5.29.2 

format: pretty-timestamped, colors: true:

[2024-03-07 19:45:46] ←[36minfo ←[39m←[37m←[34m---←[37m config file  - ←[32m/home/greybornadmin/.config/verdaccio/config.yaml←[37m←[39m
[2024-03-07 19:45:46] ←[36minfo ←[39m←[37m←[34m---←[37m using htpasswd file: ←[32m/home/greybornadmin/.config/verdaccio/htpasswd←[37m←[39m
[2024-03-07 19:45:46] ←[36minfo ←[39m←[37m←[34m---←[37m plugin successfully loaded: ←[32mverdaccio←[37m-←[32mhtpasswd←[37m←[39m
[2024-03-07 19:45:46] ←[36minfo ←[39m←[37m←[34m---←[37m plugin successfully loaded: ←[32mverdaccio←[37m-←[32maudit←[37m←[39m
[2024-03-07 19:45:46] ←[33mwarn ←[39m←[37m←[34m---←[37m http address - ←[32mhttp://0.0.0.0:4873/←[37m - ←[32mverdaccio/5.29.2←[37m←[39m

To Reproduce

Configure Verdaccio logging with (format: pretty, colors: true) or (format: pretty-timestamped, colors: false) to see the issues.

Expected behavior

If (1) the space was removed from the beginning of the first ANSI sequence when colors: true is enabled, and (2) an extra space was added to the end of the timestamp when format: pretty-timestamped is enabled, both issues would be fixed, and you'd still have the same formatting you currently have with format: pretty-timestamped, colors: true.

format: pretty, colors: true should have no space at the start of each line:

←[36minfo ←[39m←[37m←[34m---←[37m config file  - ←[32m/home/greybornadmin/.config/verdaccio/config.yaml←[37m←[39m
←[36minfo ←[39m←[37m←[34m---←[37m using htpasswd file: ←[32m/home/greybornadmin/.config/verdaccio/htpasswd←[37m←[39m
←[36minfo ←[39m←[37m←[34m---←[37m plugin successfully loaded: ←[32mverdaccio←[37m-←[32mhtpasswd←[37m←[39m
←[36minfo ←[39m←[37m←[34m---←[37m plugin successfully loaded: ←[32mverdaccio←[37m-←[32maudit←[37m←[39m
←[33mwarn ←[39m←[37m←[34m---←[37m http address - ←[32mhttp://0.0.0.0:4873/←[37m - ←[32mverdaccio/5.29.2←[37m←[39m

format: pretty-timestamped, colors: false should have a space after the timestamp, but not at the end of the line:

[2024-03-07 19:48:33] info --- config file  - /home/greybornadmin/.config/verdaccio/config.yaml
[2024-03-07 19:48:33] info --- using htpasswd file: /home/greybornadmin/.config/verdaccio/htpasswd
[2024-03-07 19:48:33] info --- plugin successfully loaded: verdaccio-htpasswd
[2024-03-07 19:48:33] info --- plugin successfully loaded: verdaccio-audit
[2024-03-07 19:48:33] warn --- http address - http://0.0.0.0:4873/ - verdaccio/5.29.2

Environment information

Environment Info:
  System:
    OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (1) x64 DO-Premium-Intel
  Binaries:
    npm: 10.5.0 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: 9.0.4 - ~/.nvm/versions/node/v20.11.1/bin/pnpm
  npmGlobalPackages:
    verdaccio: 5.30.3

Contribute to Verdaccio

  • I'm willing to fix this bug 🥇
@somethingSTRANGE somethingSTRANGE changed the title Bad log spacing depending on the FORMAT and COLOR options used Bad log spacing depending on the FORMAT and COLORS options used May 6, 2024
somethingSTRANGE added a commit to somethingSTRANGE/verdaccio that referenced this issue May 7, 2024
fixes: verdaccio#4630

inserted a space between the timestamp and the message when logging timestamped messages.
somethingSTRANGE added a commit to somethingSTRANGE/verdaccio that referenced this issue May 7, 2024
fixes: verdaccio#4630

removed padding of an unnecessary space (at the start or end of the log string, depending on whether colors are enabled).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants