Skip to content

Commit 49d4be5

Browse files
feat: further reduce log sizes
1 parent 28bd50a commit 49d4be5

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

backend/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ services:
1818
logging:
1919
driver: "json-file"
2020
options:
21-
max-size: "100m"
21+
max-size: "30m"
2222
max-file: "3"
2323

2424
networks:

backend/src/main.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! The backend is divided into multiple modules. The [`routing`] module contains all the route handlers and the [`db`] module contains all database queries and models. Other modules are utilities used throughout the backend.
44
55
use clap::Parser;
6+
use tracing_appender::rolling::{RollingFileAppender, Rotation};
67
use tracing_subscriber::prelude::*;
78

89
mod auth;
@@ -24,16 +25,25 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2425
let env_vars = env::EnvVars::parse().process()?;
2526

2627
// Initialize logger
27-
let (append_writer, _guard) = tracing_appender::non_blocking(tracing_appender::rolling::daily(
28-
env_vars
29-
.log_location
30-
.parent()
31-
.expect("Where do you want to store that log??"),
32-
env_vars
33-
.log_location
34-
.file_name()
35-
.expect("Do you want to store the logs in a directory?"),
36-
));
28+
let (append_writer, _guard) = tracing_appender::non_blocking(
29+
RollingFileAppender::builder()
30+
.rotation(Rotation::DAILY)
31+
.max_log_files(2) // Keep the last 2 days of logs
32+
.filename_prefix(
33+
env_vars
34+
.log_location
35+
.file_name()
36+
.expect("Do you want to store the logs in a directory?")
37+
.to_str()
38+
.expect("Error converting log filename to string"),
39+
)
40+
.build(
41+
env_vars
42+
.log_location
43+
.parent()
44+
.expect("Where do you want to store that log??"),
45+
)?,
46+
);
3747

3848
let subscriber = tracing_subscriber::registry()
3949
.with(

0 commit comments

Comments
 (0)