mirror of
https://github.com/nukesor/pueue
synced 2024-10-01 13:34:07 +00:00
fix: Use localtime for log output
This commit is contained in:
parent
57da8ff3a7
commit
4c27640484
|
@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||
This gives users more control over how their editor should be started.
|
||||
- Don't show the version warning message between daemon and client, when using any `--json` flag.
|
||||
- Fix some test failures in non-standard environments for NixOS test suite ([#346](https://github.com/Nukesor/pueue/issues/346)).
|
||||
- The time in pueue's logs will now be in localtime instead of UTC [#385](https://github.com/Nukesor/pueue/issues/385).
|
||||
|
||||
### Misc
|
||||
|
||||
|
|
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1556,6 +1556,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "48dfff04aade74dd495b007c831cd6f4e0cee19c344dd9dc0884c0289b70a786"
|
||||
dependencies = [
|
||||
"log",
|
||||
"termcolor",
|
||||
"time 0.3.13",
|
||||
]
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ handlebars = "4"
|
|||
pest = "2"
|
||||
pest_derive = "2"
|
||||
shell-escape = "0.1"
|
||||
simplelog = { version = "0.12", default-features = false }
|
||||
simplelog = "0.12"
|
||||
tempfile = "3"
|
||||
|
||||
chrono = { workspace = true }
|
||||
|
|
|
@ -3,7 +3,8 @@ use std::path::PathBuf;
|
|||
use anyhow::{bail, Context, Result};
|
||||
use clap::{IntoApp, Parser};
|
||||
use clap_complete::{generate_to, shells};
|
||||
use simplelog::{Config, LevelFilter, SimpleLogger};
|
||||
use log::warn;
|
||||
use simplelog::{Config, ConfigBuilder, LevelFilter, SimpleLogger};
|
||||
|
||||
use pueue_lib::settings::Settings;
|
||||
|
||||
|
@ -45,7 +46,18 @@ async fn main() -> Result<()> {
|
|||
2 => LevelFilter::Info,
|
||||
_ => LevelFilter::Debug,
|
||||
};
|
||||
SimpleLogger::init(level, Config::default()).unwrap();
|
||||
|
||||
// Try to initialize the logger with the timezone set to the Local time of the machine.
|
||||
let mut builder = ConfigBuilder::new();
|
||||
let logger_config = match builder.set_time_offset_to_local() {
|
||||
Err(_) => {
|
||||
warn!("Failed to determine the local time of this machine. Fallback to UTC.");
|
||||
Config::default()
|
||||
}
|
||||
Ok(builder) => builder.build(),
|
||||
};
|
||||
|
||||
SimpleLogger::init(level, logger_config).unwrap();
|
||||
|
||||
// Try to read settings from the configuration file.
|
||||
let (mut settings, config_found) =
|
||||
|
|
|
@ -2,7 +2,8 @@ use std::process::Command;
|
|||
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use simplelog::{Config, LevelFilter, SimpleLogger};
|
||||
use log::warn;
|
||||
use simplelog::{Config, ConfigBuilder, LevelFilter, SimpleLogger};
|
||||
|
||||
use pueue_daemon_lib::cli::CliArguments;
|
||||
use pueue_daemon_lib::run;
|
||||
|
@ -23,7 +24,18 @@ async fn main() -> Result<()> {
|
|||
2 => LevelFilter::Info,
|
||||
_ => LevelFilter::Debug,
|
||||
};
|
||||
SimpleLogger::init(level, Config::default()).unwrap();
|
||||
|
||||
// Try to initialize the logger with the timezone set to the Local time of the machine.
|
||||
let mut builder = ConfigBuilder::new();
|
||||
let logger_config = match builder.set_time_offset_to_local() {
|
||||
Err(_) => {
|
||||
warn!("Failed to determine the local time of this machine. Fallback to UTC.");
|
||||
Config::default()
|
||||
}
|
||||
Ok(builder) => builder.build(),
|
||||
};
|
||||
|
||||
SimpleLogger::init(level, logger_config).unwrap();
|
||||
|
||||
run(opt.config, opt.profile, false).await
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue