orhun / rustypaste

A minimal file upload/pastebin service.
https://blog.orhun.dev/blazingly-fast-file-sharing
MIT License
766 stars 47 forks source link

feat(log): switch to `tracing` for logging #163

Closed woshilapin closed 11 months ago

woshilapin commented 11 months ago

resolves #161

Description

Only changing env_logger into tracing-subscriber. It should support the same configuration with RUST_LOG (and more, if we convert from log to tracing later).

Motivation and Context

See #161.

How Has This Been Tested?

Logging are usually not tested. If any test would be needed, could you give some pointers?

Changelog Entry

### Changed

- Changes the logger formatter to `tracing-subscriber`

-->

Types of Changes

Checklist:

orhun commented 11 months ago

Looks great! We only need one change, see https://github.com/orhun/rustypaste/issues/161#issuecomment-1769170790

woshilapin commented 11 months ago

Looks great! We only need one change, see #161 (comment)

@orhun Sure thing, here it is in a404dfc.

codecov-commenter commented 11 months ago

Codecov Report

Attention: 20 lines in your changes are missing coverage. Please review.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Files Coverage Δ
src/auth.rs 90.90% <100.00%> (ø)
src/middleware.rs 72.00% <100.00%> (ø)
src/config.rs 82.85% <25.00%> (ø)
src/server.rs 82.87% <66.66%> (ø)
src/main.rs 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

:loudspeaker: Thoughts on this report? Let us know!.

orhun commented 11 months ago

LGTM, just one thing, can you configure tracing subscriber so that the default log level will be INFO? Because now if you run rustypaste then you get no output. We should somehow use INFO as default to not break CLI backwards compatibility.

woshilapin commented 11 months ago

LGTM, just one thing, can you configure tracing subscriber so that the default log level will be INFO? Because now if you run rustypaste then you get no output. We should somehow use INFO as default to not break CLI backwards compatibility.

@orhun Good point. Done in b18610c thanks to https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#method.from_default_env.