Skip to content

Commit 03d6eba

Browse files
authored
Merge pull request GCWing#685 from wgqqqqq/codex/flashgrep-log-isolation
chore(search): isolate flashgrep logs and bump bundle v0.2.7
2 parents cb8bb98 + e2de3a0 commit 03d6eba

14 files changed

Lines changed: 165 additions & 20 deletions

File tree

resources/flashgrep/VERSION.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"repo": "wgqqqqq/flashgrep",
3-
"tag": "v0.2.6",
4-
"published_at": "2026-05-11T06:49:11Z"
3+
"tag": "v0.2.7",
4+
"published_at": "2026-05-12T04:48:18Z"
55
}
-14 KB
Binary file not shown.
8 KB
Binary file not shown.
392 Bytes
Binary file not shown.
-73.4 KB
Binary file not shown.
-10 KB
Binary file not shown.
18.3 KB
Binary file not shown.

src/apps/desktop/src/logging.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use tauri_plugin_log::{fern, RotationStrategy, Target, TargetKind, TimezoneStrat
1414

1515
const SESSION_DIR_PATTERN: &str = r"^\d{8}T\d{6}$";
1616
const MAX_LOG_SESSIONS: usize = 10;
17+
const FLASHGREP_LOG_TARGET_PREFIX: &str = "flashgrep";
1718
static SESSION_LOG_DIR: OnceLock<PathBuf> = OnceLock::new();
1819
// Default to Debug in early development for easier diagnostics
1920
static CURRENT_LOG_LEVEL: AtomicU8 = AtomicU8::new(level_filter_to_u8(log::LevelFilter::Debug));
@@ -157,6 +158,7 @@ pub struct RuntimeLoggingInfo {
157158
pub session_log_dir: String,
158159
pub app_log_path: String,
159160
pub ai_log_path: String,
161+
pub flashgrep_log_path: String,
160162
pub webview_log_path: String,
161163
}
162164

@@ -169,13 +171,21 @@ pub fn get_runtime_logging_info() -> RuntimeLoggingInfo {
169171
session_log_dir: session_dir.to_string_lossy().to_string(),
170172
app_log_path: session_dir.join("app.log").to_string_lossy().to_string(),
171173
ai_log_path: session_dir.join("ai.log").to_string_lossy().to_string(),
174+
flashgrep_log_path: session_dir
175+
.join("flashgrep.log")
176+
.to_string_lossy()
177+
.to_string(),
172178
webview_log_path: session_dir
173179
.join("webview.log")
174180
.to_string_lossy()
175181
.to_string(),
176182
}
177183
}
178184

185+
fn is_flashgrep_target(target: &str) -> bool {
186+
target.starts_with(FLASHGREP_LOG_TARGET_PREFIX)
187+
}
188+
179189
pub fn create_session_log_dir() -> PathBuf {
180190
let logs_root = resolve_logs_root();
181191

@@ -205,7 +215,9 @@ pub fn build_log_targets(config: &LogConfig) -> Vec<Target> {
205215
Target::new(TargetKind::Stdout)
206216
.filter(|metadata| {
207217
let target = metadata.target();
208-
!target.starts_with("ai") && !target.starts_with("webview")
218+
!target.starts_with("ai")
219+
&& !target.starts_with("webview")
220+
&& !is_flashgrep_target(target)
209221
})
210222
.format(|out, message, record| {
211223
let target = record.target();
@@ -246,7 +258,9 @@ pub fn build_log_targets(config: &LogConfig) -> Vec<Target> {
246258
})
247259
.filter(|metadata| {
248260
let target = metadata.target();
249-
!target.starts_with("ai") && !target.starts_with("webview")
261+
!target.starts_with("ai")
262+
&& !target.starts_with("webview")
263+
&& !is_flashgrep_target(target)
250264
})
251265
.format(format_log_plain),
252266
);
@@ -261,6 +275,16 @@ pub fn build_log_targets(config: &LogConfig) -> Vec<Target> {
261275
.format(format_log_plain),
262276
);
263277

278+
let flashgrep_log_dir = session_dir.clone();
279+
targets.push(
280+
Target::new(TargetKind::Folder {
281+
path: flashgrep_log_dir,
282+
file_name: Some("flashgrep".into()),
283+
})
284+
.filter(|metadata| is_flashgrep_target(metadata.target()))
285+
.format(format_log_plain),
286+
);
287+
264288
let webview_log_dir = session_dir;
265289
targets.push(
266290
Target::new(TargetKind::Folder {
@@ -289,6 +313,7 @@ pub fn build_log_plugin<R: Runtime>(log_targets: Vec<Target>) -> TauriPlugin<R>
289313
.level_for("h2", log::LevelFilter::Info)
290314
.level_for("portable_pty", log::LevelFilter::Info)
291315
.level_for("russh", log::LevelFilter::Info)
316+
.level_for("grep_searcher", log::LevelFilter::Warn)
292317
.targets(log_targets)
293318
.rotation_strategy(RotationStrategy::KeepSome(2)) // 1 active + 2 backups
294319
.max_file_size(10 * 1024 * 1024)

src/crates/core/src/service/search/flashgrep/client.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use tokio::{
1919

2020
use super::{
2121
error::{AppError, Result},
22+
log_flashgrep_stderr_line, FLASHGREP_LOG_TARGET,
2223
protocol::{
2324
ClientCapabilities, ClientInfo, GlobParams, InitializeParams, RepoRef, Request, Response,
2425
SearchParams, TaskRef,
@@ -169,6 +170,7 @@ impl ManagedClient {
169170
self.clear_daemon_if_current(&daemon).await;
170171
if let Err(shutdown_error) = daemon.shutdown().await {
171172
log::debug!(
173+
target: FLASHGREP_LOG_TARGET,
172174
"Flashgrep stdio daemon shutdown after transport error failed: {}",
173175
shutdown_error
174176
);
@@ -469,6 +471,7 @@ impl AsyncDaemonClient {
469471
.await;
470472
if let Err(terminate_error) = client.wait_for_child_exit().await {
471473
log::debug!(
474+
target: FLASHGREP_LOG_TARGET,
472475
"Flashgrep stdio daemon cleanup after failed startup errored: {}",
473476
terminate_error
474477
);
@@ -584,14 +587,22 @@ impl AsyncDaemonClient {
584587
let mut writer = BufWriter::new(stdin);
585588
while let Some(outbound) = write_rx.recv().await {
586589
if let Err(error) = writer.write_all(&outbound).await {
587-
log::debug!("flashgrep stdio daemon stdin write failed: {}", error);
590+
log::debug!(
591+
target: FLASHGREP_LOG_TARGET,
592+
"flashgrep stdio daemon stdin write failed: {}",
593+
error
594+
);
588595
protocol
589596
.close_with_message("flashgrep stdio backend stdin write failed")
590597
.await;
591598
return;
592599
}
593600
if let Err(error) = writer.flush().await {
594-
log::debug!("flashgrep stdio daemon stdin flush failed: {}", error);
601+
log::debug!(
602+
target: FLASHGREP_LOG_TARGET,
603+
"flashgrep stdio daemon stdin flush failed: {}",
604+
error
605+
);
595606
protocol
596607
.close_with_message("flashgrep stdio backend stdin flush failed")
597608
.await;
@@ -639,9 +650,13 @@ impl AsyncDaemonClient {
639650
line.clear();
640651
match reader.read_line(&mut line).await {
641652
Ok(0) => break,
642-
Ok(_) => log::debug!("flashgrep stdio daemon stderr: {}", line.trim_end()),
653+
Ok(_) => log_flashgrep_stderr_line(&line),
643654
Err(error) => {
644-
log::debug!("flashgrep stdio daemon stderr read failed: {}", error);
655+
log::debug!(
656+
target: FLASHGREP_LOG_TARGET,
657+
"flashgrep stdio daemon stderr read failed: {}",
658+
error
659+
);
645660
break;
646661
}
647662
}

src/crates/core/src/service/search/flashgrep/mod.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,44 @@ mod repo_session;
55
mod rpc_client;
66
mod types;
77

8+
pub(crate) const FLASHGREP_LOG_TARGET: &str = "flashgrep";
9+
10+
pub(crate) fn log_flashgrep_stderr_line(line: &str) {
11+
log_flashgrep_stderr_line_with_context(None, line);
12+
}
13+
14+
pub(crate) fn log_flashgrep_stderr_line_with_context(context: Option<&str>, line: &str) {
15+
let trimmed = line.trim();
16+
if trimmed.is_empty() {
17+
return;
18+
}
19+
20+
if let Some(rest) = trimmed.strip_prefix("flashgrep[") {
21+
if let Some((area, rest)) = rest.split_once("][") {
22+
if let Some((level, message)) = rest.split_once("] ") {
23+
let formatted = match context {
24+
Some(context) => format!("flashgrep[{area}] {context} {message}"),
25+
None => format!("flashgrep[{area}] {message}"),
26+
};
27+
match level {
28+
"error" => log::error!(target: FLASHGREP_LOG_TARGET, "{formatted}"),
29+
"warn" => log::warn!(target: FLASHGREP_LOG_TARGET, "{formatted}"),
30+
"info" => log::info!(target: FLASHGREP_LOG_TARGET, "{formatted}"),
31+
"debug" => log::debug!(target: FLASHGREP_LOG_TARGET, "{formatted}"),
32+
"trace" => log::trace!(target: FLASHGREP_LOG_TARGET, "{formatted}"),
33+
_ => log::debug!(target: FLASHGREP_LOG_TARGET, "{trimmed}"),
34+
}
35+
return;
36+
}
37+
}
38+
}
39+
40+
match context {
41+
Some(context) => log::debug!(target: FLASHGREP_LOG_TARGET, "{context} {trimmed}"),
42+
None => log::debug!(target: FLASHGREP_LOG_TARGET, "{trimmed}"),
43+
}
44+
}
45+
846
pub(crate) use client::{ManagedClient, RepoSession};
947
pub(crate) use protocol::{
1048
ClientCapabilities, ClientInfo, FileMatch, GlobParams, InitializeParams, MatchLocation,

0 commit comments

Comments
 (0)