1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 13:23:34 +00:00

Improve desktop IPC logging (#11864)

* Improve desktop IPC logging

* Log error

* Force file to only log info, like the desktop app does

* use ?
This commit is contained in:
Daniel García
2024-11-14 17:45:19 +01:00
committed by GitHub
parent ef127fd26e
commit d0f24dc41f
5 changed files with 38 additions and 6 deletions

View File

@@ -8,14 +8,14 @@ use tokio_util::codec::LengthDelimitedCodec;
#[cfg(target_os = "macos")]
embed_plist::embed_info_plist!("../../../resources/info.desktop_proxy.plist");
fn init_logging(log_path: &Path, level: log::LevelFilter) {
fn init_logging(log_path: &Path, console_level: LevelFilter, file_level: LevelFilter) {
use simplelog::{ColorChoice, CombinedLogger, Config, SharedLogger, TermLogger, TerminalMode};
let config = Config::default();
let mut loggers: Vec<Box<dyn SharedLogger>> = Vec::new();
loggers.push(TermLogger::new(
level,
console_level,
config.clone(),
TerminalMode::Stderr,
ColorChoice::Auto,
@@ -23,7 +23,7 @@ fn init_logging(log_path: &Path, level: log::LevelFilter) {
match std::fs::File::create(log_path) {
Ok(file) => {
loggers.push(simplelog::WriteLogger::new(level, config, file));
loggers.push(simplelog::WriteLogger::new(file_level, config, file));
}
Err(e) => {
eprintln!("Can't create file: {}", e);
@@ -57,7 +57,12 @@ async fn main() {
path
};
init_logging(&log_path, LevelFilter::Info);
let level = std::env::var("PROXY_LOG_LEVEL")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or(LevelFilter::Info);
init_logging(&log_path, level, LevelFilter::Info);
info!("Starting Bitwarden IPC Proxy.");