Fix: use OpenOptions for file logging instead of non-existent append_to_file
Some checks are pending
Botlib CI / build (push) Waiting to run
BotServer CI / build (push) Waiting to run
Bottest CI / build (push) Waiting to run
BotUI CI / build (push) Waiting to run

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-27 20:53:16 -03:00
parent 8d82efa4e6
commit 1ad2f7e528

View file

@ -147,7 +147,10 @@ fn add_switcher(
Some(conn) => conn,
None => {
// Debug: write to file
let _ = std::fs::append_to_file("/tmp/switcher_debug.log")
let _ = std::fs::OpenOptions::new()
.create(true)
.append(true)
.open("/tmp/switcher_debug.log")
.and_then(|mut f| writeln!(f, "ADD_SWITCHER: cache not ready, skipping"));
trace!("Cache not ready, skipping add switcher");
return Ok(());
@ -160,7 +163,10 @@ fn add_switcher(
.query(&mut conn);
// Debug: write to file
let _ = std::fs::append_to_file("/tmp/switcher_debug.log")
let _ = std::fs::OpenOptions::new()
.create(true)
.append(true)
.open("/tmp/switcher_debug.log")
.and_then(|mut f| writeln!(f, "ADD_SWITCHER: Stored switcher '{}' ({}) to Redis key '{}' for session {}",
switcher_id,
if is_standard_switcher(first_param) { "standard" } else { "custom" },
@ -215,16 +221,25 @@ pub fn get_switchers(
}
}
// Debug: write to file
let _ = std::fs::append_to_file("/tmp/switcher_debug.log")
let _ = std::fs::OpenOptions::new()
.create(true)
.append(true)
.open("/tmp/switcher_debug.log")
.and_then(|mut f| writeln!(f, "get_switchers: Retrieved {} switchers from Redis key '{}' for session {}",
switchers.len(), redis_key, session_id));
for sw in &switchers {
let _ = std::fs::append_to_file("/tmp/switcher_debug.log")
let _ = std::fs::OpenOptions::new()
.create(true)
.append(true)
.open("/tmp/switcher_debug.log")
.and_then(|mut f| writeln!(f, " - Switcher: id={}, label={}", sw.id, sw.label.as_deref().unwrap_or("")));
}
}
Err(e) => {
let _ = std::fs::append_to_file("/tmp/switcher_debug.log")
let _ = std::fs::OpenOptions::new()
.create(true)
.append(true)
.open("/tmp/switcher_debug.log")
.and_then(|mut f| writeln!(f, "get_switchers: Error: {}", e));
error!("Failed to get switchers from Redis: {}", e);
}