Write user notifications to streamer's log file

This commit is contained in:
Marcin Kulik
2024-02-08 11:53:20 +01:00
parent 4fa684b74a
commit 0478bf06f0
3 changed files with 19 additions and 1 deletions

13
Cargo.lock generated
View File

@@ -115,6 +115,7 @@ dependencies = [
"tokio",
"tokio-stream",
"tower-http",
"tracing",
"tracing-subscriber",
"uuid",
"which",
@@ -2281,9 +2282,21 @@ checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
dependencies = [
"log",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.38",
]
[[package]]
name = "tracing-core"
version = "0.1.32"

View File

@@ -33,4 +33,5 @@ tokio-stream = { version = "0.1.14", features = ["sync"] }
rust-embed = "8.2.0"
mime_guess = "2.0.4"
tower-http = { version = "0.5.1", features = ["trace"] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

View File

@@ -11,6 +11,7 @@ use std::net::{self, TcpListener};
use std::thread;
use std::time::Instant;
use tokio::sync::{mpsc, oneshot};
use tracing::info;
pub struct Streamer {
record_input: bool,
@@ -66,8 +67,11 @@ impl Streamer {
}
fn notify<S: ToString>(&self, message: S) {
let message = message.to_string();
info!(message);
self.notifier_tx
.send(message.to_string())
.send(message)
.expect("notification send should succeed");
}
}