add file rotate for logging
This commit is contained in:
parent
8c731a3b55
commit
9a78018e15
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,4 +8,7 @@
|
|||||||
# exclude binarys in examples folder
|
# exclude binarys in examples folder
|
||||||
/examples/*
|
/examples/*
|
||||||
!/examples/*.rs
|
!/examples/*.rs
|
||||||
|
|
||||||
|
# exlcude logging
|
||||||
*.log
|
*.log
|
||||||
|
/logs/
|
||||||
|
48
Cargo.lock
generated
48
Cargo.lock
generated
@ -2,6 +2,12 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "adler"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "0.7.18"
|
version = "0.7.18"
|
||||||
@ -89,6 +95,15 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crc32fast"
|
||||||
|
version = "1.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ffplayout-engine-rs"
|
name = "ffplayout-engine-rs"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -96,6 +111,7 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"ffprobe",
|
"ffprobe",
|
||||||
|
"file-rotate",
|
||||||
"log",
|
"log",
|
||||||
"notify",
|
"notify",
|
||||||
"rand",
|
"rand",
|
||||||
@ -117,6 +133,16 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "file-rotate"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f8071df7315b1cd4006ce687043f393cca212761889b3626c1444ae06e8f72d0"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"flate2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filetime"
|
name = "filetime"
|
||||||
version = "0.2.15"
|
version = "0.2.15"
|
||||||
@ -129,6 +155,18 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flate2"
|
||||||
|
version = "1.0.22"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"crc32fast",
|
||||||
|
"libc",
|
||||||
|
"miniz_oxide",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fsevent"
|
name = "fsevent"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
@ -290,6 +328,16 @@ version = "2.4.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "miniz_oxide"
|
||||||
|
version = "0.4.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
|
||||||
|
dependencies = [
|
||||||
|
"adler",
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "0.6.23"
|
version = "0.6.23"
|
||||||
|
15
Cargo.toml
15
Cargo.toml
@ -6,18 +6,19 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
|
||||||
serde_yaml = "0.8"
|
|
||||||
serde_json = "1.0"
|
|
||||||
regex = "1"
|
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
clap = { version = "3.0.14", features = ["derive"] }
|
clap = { version = "3.0.14", features = ["derive"] }
|
||||||
notify = "4.0.0"
|
|
||||||
walkdir = "2"
|
|
||||||
rand = "0.8.5"
|
|
||||||
ffprobe = "0.3"
|
ffprobe = "0.3"
|
||||||
|
file-rotate = "0.6.0"
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
|
notify = "4.0.0"
|
||||||
|
rand = "0.8.5"
|
||||||
|
regex = "1"
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde_json = "1.0"
|
||||||
|
serde_yaml = "0.8"
|
||||||
simplelog = { version = "^0.11.2", features = ["paris"] }
|
simplelog = { version = "^0.11.2", features = ["paris"] }
|
||||||
|
walkdir = "2"
|
||||||
|
|
||||||
# tokio = { version = "1.16.1", features = ["full"] }
|
# tokio = { version = "1.16.1", features = ["full"] }
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
@ -3,10 +3,10 @@ extern crate simplelog;
|
|||||||
|
|
||||||
use simplelog::*;
|
use simplelog::*;
|
||||||
|
|
||||||
use std::fs::File;
|
use file_rotate::{FileRotate, ContentLimit, suffix::AppendCount, compression::Compression};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
TermLogger::init(LevelFilter::Debug, Config::default(), TerminalMode::Mixed, ColorChoice::Auto).unwrap();
|
//TermLogger::init(LevelFilter::Debug, Config::default(), TerminalMode::Mixed, ColorChoice::Auto).unwrap();
|
||||||
//SimpleLogger::init(LevelFilter::Debug, Config::default()).unwrap();
|
//SimpleLogger::init(LevelFilter::Debug, Config::default()).unwrap();
|
||||||
// CombinedLogger::init(
|
// CombinedLogger::init(
|
||||||
// vec![
|
// vec![
|
||||||
@ -15,7 +15,18 @@ fn main() {
|
|||||||
// ]
|
// ]
|
||||||
// ).unwrap();
|
// ).unwrap();
|
||||||
|
|
||||||
error!("Bright red error");
|
let log = || {
|
||||||
info!("This only appears in <red>the log file</>");
|
FileRotate::new(
|
||||||
debug!("This level is <b>currently</b> not enabled for any logger");
|
"logs/ffplayout.log",
|
||||||
|
AppendCount::new(7),
|
||||||
|
ContentLimit::Lines(1000),
|
||||||
|
Compression::None,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
WriteLogger::init(LevelFilter::Debug, Config::default(), log()).unwrap();
|
||||||
|
|
||||||
|
for idx in 1..1500 {
|
||||||
|
info!("{idx}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user