Closed maxwai closed 10 months ago
For the formatting of console and log file, would https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/format/struct.Compact.html be fine? The source location of the message isn't padded, but I think it should be good
For the formatting of console and log file, would https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/format/struct.Compact.html be fine? The source location of the message isn't padded, but I think it should be good
Yes that looks fine
Is log rotation based on file sized a fixed requirement? The tracing_appender
crate (part of the tracing
ecosystem) only has support for time-based log rotation (i.e. hourly, daily, etc.), and while there exists another crate for this (rolling_file
), it's not part of tracing itself, and I'm not sure about how active it is.
Is log rotation based on file sized a fixed requirement? The
tracing_appender
crate (part of thetracing
ecosystem) only has support for time-based log rotation (i.e. hourly, daily, etc.), and while there exists another crate for this (rolling_file
), it's not part of tracing itself, and I'm not sure about how active it is.
I think time based rotation should be fine. If we set it to 7 days
I should mention, I've ended up just using size-based rotation based on rolling_file - both tracing_appender and rolling_file only have support for time-based log-rotation every minute hour and day, but no week/custom duration option.
Configure tracing so that all logs are send to the console, to a file in
./appdata/logs/
.The file should have log rotation if possible (keep X files at a maximum of Y MB).
As for formatting of the console and file messages (will be the same) try something like:
If there are more characteristics that could be good to log, add them. Everything except the message should be limited in length and padded to length so that, if you look at the logs, everything looks linear.
Additionally, make a subscriber that can be used to send the log to a discord channel. At creation, the subscriber gets a Bot Context, a guild id and a channel id. He also gets a flag if only log messages intended for his guild should be send or all. The subscriber can figure out from what guild a message is by reading the optional argument
guild_id
. For the formatting of the log messages to discord, just the message and Level is fine.