Skip to content

Commit d35692c

Browse files
committed
fix: suppress noisy ort/hnsw_rs logs in production, clean up clippy
1 parent f2731af commit d35692c

2 files changed

Lines changed: 11 additions & 14 deletions

File tree

src/embedder.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,16 @@ impl Embedder {
3636

3737
// Download model if missing.
3838
if !model_path.exists() {
39-
let expected_sha: Option<&str> = if MODEL_SHA256.is_empty() {
40-
None
41-
} else {
42-
Some(MODEL_SHA256)
43-
};
44-
download_file(MODEL_URL, &model_path, expected_sha)?;
39+
download_file(MODEL_URL, &model_path, Some(MODEL_SHA256))?;
4540
}
4641

4742
// Download tokenizer if missing.
4843
if !tokenizer_path.exists() {
4944
download_file(TOKENIZER_URL, &tokenizer_path, None)?;
5045
}
5146

52-
// Verify model hash if we have one.
53-
if !MODEL_SHA256.is_empty() {
54-
verify_sha256(&model_path, MODEL_SHA256)?;
55-
}
47+
// Verify model hash.
48+
verify_sha256(&model_path, MODEL_SHA256)?;
5649

5750
let session = Session::builder()
5851
.with_context(|| "creating ONNX session builder")?

src/main.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use anyhow::Result;
77
use clap::{Parser, Subcommand};
88
use std::io::{self, BufRead, Write};
99
use std::path::PathBuf;
10-
use tracing::info;
1110

1211
use config::Config;
1312

@@ -89,18 +88,23 @@ fn remove_dir_if_exists(path: &std::path::Path) -> Result<bool> {
8988
fn main() -> Result<()> {
9089
let cli = Cli::parse();
9190

92-
// Set up tracing.
93-
let filter = if cli.verbose { "debug" } else { "info" };
91+
// Set up tracing. Default: suppress all logs (ort and hnsw_rs are very noisy).
92+
// --verbose enables debug for engraph, info for everything else.
93+
let filter = if cli.verbose {
94+
"engraph=debug,info"
95+
} else {
96+
"error"
97+
};
9498
tracing_subscriber::fmt()
9599
.with_env_filter(
96100
tracing_subscriber::EnvFilter::try_from_default_env()
97101
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(filter)),
98102
)
103+
.with_writer(std::io::stderr)
99104
.init();
100105

101106
let mut cfg = Config::load()?;
102107
let data_dir = Config::data_dir()?;
103-
info!(data_dir = %data_dir.display(), "loaded config");
104108

105109
match cli.command {
106110
Command::Index { path, rebuild } => {

0 commit comments

Comments
 (0)