aquelemiguel / parrot

🦜 A hassle-free, highly performant, self-hosted Discord music bot with YouTube and Spotify support. Powered by yt-dlp.
MIT License
136 stars 44 forks source link

Add logging capabilities #142

Closed afonsojramos closed 2 years ago

afonsojramos commented 2 years ago

Rationale

When we have a deployed Parrot it is very useful to have logs in a file. I have actually had an occasion where the deployed parrot crashed for no reason in specific, and even after accessing the container logs I could not see anything. This would be solved by logging stuff into a file.

Description

Implement an in-house logger/a logging framework.

Reference

Logging crates

afonsojramos commented 2 years ago

@aquelemiguel @joao-conde do you already have any preference over any logging framework?

joao-conde commented 2 years ago

@afonsojramos nope, up to you. Do some due diligence and present some of your preferred choices.

But this one seems official: https://github.com/rust-lang/log Its part of the rust-lang organization itself.

afonsojramos commented 2 years ago

Will do! The official log crate is a red herring, since it is only a facade. Most loggers that I listed actually implement said facade.

joao-conde commented 2 years ago

Ah, I see. All of these sound good: image

But what stops me from using these macros?

image

afonsojramos commented 2 years ago

But what stops me from using these macros?

Nothing 😅

joao-conde commented 2 years ago

I think the lib we choose should cover the following: 1 - be as simple as possible, guaranteeing the next 2 - having simple functions/macros to output text at multiple levels (info debug error) 3 - being able to control where to send the logs through env vars (console, file, both, etc)

These properties allow us to set debug variables like LEVEL=DEBUG and LOG=CONSOLE for local development and debugging or LEVEL=ERROR and LOG=FILE for our deployment.

afonsojramos commented 2 years ago

This ended up being something that is not needed as the overhead is too much for little benefit since we can simply run docker logs to check out the logs of the container.

I raised this issue because I was passing without my knowledge, due to lazydocker's defaults, the flag --since=60m, which would block me from seeing a lot of logs.