logging improvements

This commit is contained in:
Alex Janka 2024-01-15 10:22:10 +11:00
parent 27c8697899
commit 3f19aaa7c3
4 changed files with 13 additions and 3 deletions

2
Cargo.lock generated
View file

@ -2256,7 +2256,7 @@ dependencies = [
[[package]] [[package]]
name = "tesla-charge-controller" name = "tesla-charge-controller"
version = "0.2.4" version = "0.2.5"
dependencies = [ dependencies = [
"async-channel", "async-channel",
"chrono", "chrono",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "tesla-charge-controller" name = "tesla-charge-controller"
version = "0.2.4" version = "0.2.5"
edition = "2021" edition = "2021"
license = "MITNFA" license = "MITNFA"
description = "Controls Tesla charge rate based on solar charge data" description = "Controls Tesla charge rate based on solar charge data"

1
debian/service vendored
View file

@ -9,6 +9,7 @@ Restart=always
RestartSec=10s RestartSec=10s
User=tesla User=tesla
Environment="RUST_LOG=error,warn" Environment="RUST_LOG=error,warn"
Environment="LOG_TIMESTAMP=false"
ExecStart=/usr/bin/tesla-charge-controller watch ExecStart=/usr/bin/tesla-charge-controller watch
[Install] [Install]

View file

@ -39,7 +39,16 @@ enum Commands {
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
let args = Args::parse(); let args = Args::parse();
env_logger::init(); env_logger::builder()
.format_module_path(false)
.format_timestamp(
if std::env::var("LOG_TIMESTAMP").is_ok_and(|v| v == "false") {
None
} else {
Some(env_logger::TimestampPrecision::Seconds)
},
)
.init();
let auth_path = args.config_dir.join("auth"); let auth_path = args.config_dir.join("auth");