Skip to content

Commit

Permalink
refactor: remove log files; get logs via Loki directly
Browse files Browse the repository at this point in the history
  • Loading branch information
David Gomes authored and David Gomes committed Sep 22, 2023
1 parent 16ae24e commit 303059d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
5 changes: 0 additions & 5 deletions server/docker/config/promtail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,3 @@ scrape_configs:
labels:
job: rusty-plugins
__path__: /var/log/rusty-controller/**/*.log
- targets:
- localhost
labels:
job: rusty-server
__path__: /var/log/rusty-controller/**/daily**
11 changes: 1 addition & 10 deletions server/src/tracing_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,13 @@ fn build_loki_layer() -> (tracing_loki::Layer, BackgroundTask) {
}

pub async fn setup_loki() {
let directory = fs::create_dir_all("/var/log/rusty-controller/server")
.await
.map(|_| {
tracing::info!("Failed to create directory in /var/log. Using ./logs");
LOGS_DIRECTORY
})
.unwrap_or("logs");

let file = tracing_appender::rolling::daily(directory, "daily");
let filter = filter::Targets::new()
.with_target("rusty_controller", Level::DEBUG)
.with_default(Level::WARN);

let registry = tracing_subscriber::registry().with(filter).with(
fmt::layer()
.with_writer(io::stdout.and(file))
.with_writer(io::stdout)
);

let http = Client::new();
Expand Down

0 comments on commit 303059d

Please sign in to comment.