logging
This commit is contained in:
parent
d58633ca54
commit
192731dcd3
39
Cargo.lock
generated
39
Cargo.lock
generated
|
@ -534,6 +534,19 @@ dependencies = [
|
|||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece"
|
||||
dependencies = [
|
||||
"humantime",
|
||||
"is-terminal",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
|
@ -812,6 +825,12 @@ version = "1.0.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.28"
|
||||
|
@ -2153,6 +2172,15 @@ dependencies = [
|
|||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "terminal_size"
|
||||
version = "0.1.17"
|
||||
|
@ -2171,7 +2199,9 @@ dependencies = [
|
|||
"async-channel",
|
||||
"chrono",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"include_dir",
|
||||
"log",
|
||||
"metrics",
|
||||
"metrics-prometheus",
|
||||
"prometheus",
|
||||
|
@ -2698,6 +2728,15 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
|
|
|
@ -27,3 +27,5 @@ async-channel = "2.1"
|
|||
metrics = "0.22"
|
||||
metrics-prometheus = "0.6.0"
|
||||
prometheus = "0.13"
|
||||
env_logger = "0.10"
|
||||
log = "0.4"
|
||||
|
|
3
debian/service
vendored
3
debian/service
vendored
|
@ -6,8 +6,9 @@ StartLimitIntervalSec=0
|
|||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
RestartSec=10s
|
||||
User=tesla
|
||||
Environment="RUST_LOG=error,warn,info"
|
||||
ExecStart=/usr/bin/tesla-charge-controller watch
|
||||
|
||||
[Install]
|
||||
|
|
|
@ -71,7 +71,7 @@ impl TeslaInterface {
|
|||
let mut api = FleetApi::new(key.access_token, key.refresh_token);
|
||||
api.refresh().await?;
|
||||
let last_refresh = Instant::now();
|
||||
println!("Refreshed auth key");
|
||||
info!("Refreshed auth key");
|
||||
let vehicle = api
|
||||
.products()
|
||||
.await?
|
||||
|
@ -106,12 +106,12 @@ impl TeslaInterface {
|
|||
refresh_token: self.api.refresh_token.clone(),
|
||||
})?,
|
||||
)?;
|
||||
println!("Auth successfully saved");
|
||||
info!("Auth successfully saved");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn refresh(&mut self) {
|
||||
println!("refreshing...");
|
||||
info!("refreshing keys...");
|
||||
self.refresh_keys().await;
|
||||
self.refresh_state().await;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ impl TeslaInterface {
|
|||
state.climate_state = Some(new_climate_state);
|
||||
}
|
||||
}
|
||||
Err(e) => eprintln!("Error getting state: {e:#?}"),
|
||||
Err(e) => error!("Error getting state: {e:#?}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,10 +156,10 @@ impl TeslaInterface {
|
|||
let now = Instant::now();
|
||||
match self.save_key() {
|
||||
Ok(_) => self.last_refresh = now,
|
||||
Err(e) => eprintln!("error saving auth token: {e:?}"),
|
||||
Err(e) => error!("error saving auth token: {e:?}"),
|
||||
}
|
||||
}
|
||||
Err(e) => eprintln!("error refreshing auth token: {e:?}"),
|
||||
Err(e) => error!("error refreshing auth token: {e:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ enum Commands {
|
|||
#[tokio::main]
|
||||
async fn main() {
|
||||
let args = Args::parse();
|
||||
env_logger::init();
|
||||
|
||||
let auth_path = args.config_dir.join("auth");
|
||||
let config_path = args.config_dir.join("config");
|
||||
|
@ -66,7 +67,7 @@ async fn main() {
|
|||
_ = interval.tick() => interface.refresh().await,
|
||||
message = receiver.recv() => match message {
|
||||
Ok(message) => interface.process_request(message).await,
|
||||
Err(e) => eprintln!("Error on receive channel: {e:#?}")
|
||||
Err(e) => error!("Error on receive channel: {e:#?}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +75,7 @@ async fn main() {
|
|||
|
||||
server_handle.await;
|
||||
}
|
||||
Err(e) => println!("{}", e.error_string()),
|
||||
Err(e) => error!("{}", e.error_string()),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,11 @@ impl TryFrom<teslatte::vehicles::ClimateState> for ClimateState {
|
|||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(value: teslatte::vehicles::ClimateState) -> Result<Self, Self::Error> {
|
||||
log::info!(
|
||||
"Current cabin overheat protection state: {}",
|
||||
value.cabin_overheat_protection
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
inside_temp: value
|
||||
.inside_temp
|
||||
|
|
3
watch.sh
3
watch.sh
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
(
|
||||
trap 'kill 0' SIGINT
|
||||
cargo watch -w "src" -x check -s 'touch .trigger' &
|
||||
cargo watch --no-vcs-ignores -w .trigger -x "run -- --config-dir test-config watch"
|
||||
RUST_LOG=error,warn,info cargo watch --no-vcs-ignores -w .trigger -x "run -- --config-dir test-config watch"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue