Skip to content

Commit 35c097a

Browse files
committed
feat(rust): Parameterize hardcoded qchat.log references
- Import CHAT_BINARY_NAME in chat-cli/src/logging.rs - Import CHAT_BINARY_NAME in fig_log/src/lib.rs - Import CHAT_BINARY_NAME in chat-cli/src/cli/mod.rs - Replace hardcoded 'qchat.log' with format string using CHAT_BINARY_NAME 🤖 Assisted by Amazon Q Developer
1 parent 55de728 commit 35c097a

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

crates/chat-cli/src/cli/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ use crate::logging::{
4848
use crate::os::Os;
4949
use crate::util::directories::logs_dir;
5050
use crate::util::{
51+
CHAT_BINARY_NAME,
5152
CLI_BINARY_NAME,
5253
GOV_REGIONS,
5354
};
@@ -216,7 +217,11 @@ impl Cli {
216217
},
217218
log_to_stdout: std::env::var_os("Q_LOG_STDOUT").is_some() || self.verbose > 0,
218219
log_file_path: match subcommand {
219-
RootSubcommand::Chat { .. } => Some(logs_dir().expect("home dir must be set").join("qchat.log")),
220+
RootSubcommand::Chat { .. } => Some(
221+
logs_dir()
222+
.expect("home dir must be set")
223+
.join(format!("{CHAT_BINARY_NAME}.log")),
224+
),
220225
_ => None,
221226
},
222227
delete_old_log_file: false,

crates/chat-cli/src/logging.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use tracing_subscriber::{
1414
fmt,
1515
};
1616

17+
use crate::util::consts::CHAT_BINARY_NAME;
1718
use crate::util::env_var::Q_LOG_LEVEL;
1819

1920
const MAX_FILE_SIZE: u64 = 10 * 1024 * 1024;
@@ -76,7 +77,7 @@ pub fn initialize_logging<T: AsRef<Path>>(args: LogArgs<T>) -> Result<LogGuard,
7677

7778
// Make the log path parent directory if it doesn't exist.
7879
if let Some(parent) = log_path.parent() {
79-
if log_path.ends_with("qchat.log") {
80+
if log_path.ends_with(format!("{CHAT_BINARY_NAME}.log")) {
8081
mcp_path = Some(parent.to_path_buf());
8182
}
8283
std::fs::create_dir_all(parent)?;

crates/fig_log/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::fs::File;
22
use std::path::Path;
33
use std::sync::Mutex;
44

5+
use fig_util::CHAT_BINARY_NAME;
56
use fig_util::env_var::Q_LOG_LEVEL;
67
use thiserror::Error;
78
use tracing::info;
@@ -75,7 +76,7 @@ pub fn initialize_logging<T: AsRef<Path>>(args: LogArgs<T>) -> Result<LogGuard,
7576

7677
// Make the log path parent directory if it doesn't exist.
7778
if let Some(parent) = log_path.parent() {
78-
if log_path.ends_with("qchat.log") {
79+
if log_path.ends_with(format!("{CHAT_BINARY_NAME}.log")) {
7980
mcp_path = Some(parent.to_path_buf());
8081
}
8182
std::fs::create_dir_all(parent)?;

0 commit comments

Comments
 (0)