Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/src/guide/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ logging subscriber that logs to stderr.
The Python/Java logger can be configured with several environment variables:

- `LANCE_LOG`: Controls log filtering based on log level and target. See the [env_logger](https://docs.rs/env_logger/latest/env_logger/) docs for more details. The `LANCE_LOG` environment variable replaces the `RUST_LOG` environment variable.
- `LANCE_TRACING`: Controls tracing filtering based on log level. Key tracing events described below are emitted at
the `info` level. However, additional spans and events are available at the `debug` level which may be useful for
debugging performance issues. The default tracing level is `info`.
- `LANCE_LOG_STYLE`: Controls whether colors are used in the log messages. Valid values are `auto`, `always`, `never`.
- `LANCE_LOG_TS_PRECISION`: The precision of the timestamp in the log messages. Valid values are `ns`, `us`, `ms`, `s`.
- `LANCE_LOG_FILE`: Redirects Rust log messages to the specified file path instead of stderr. When set, Lance will create the file and any necessary parent directories. If the file cannot be created (e.g., due to permission issues), Lance will fall back to logging to stderr.
Expand Down
12 changes: 10 additions & 2 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,17 @@ pub fn init_logging(mut log_builder: Builder) {

let max_level = logger.filter();

let log_level = max_level.to_level().unwrap_or(Level::Error);
let trace_level = env::var("LANCE_TRACING").unwrap_or_default().to_lowercase();
let trace_level = match trace_level.as_str() {
"debug" => Level::Debug,
"info" => Level::Info,
"warn" => Level::Warn,
"error" => Level::Error,
"trace" => Level::Trace,
_ => Level::Info,
};

tracing::initialize_tracing(log_level);
tracing::initialize_tracing(trace_level);
log::set_boxed_logger(Box::new(logger)).unwrap();
log::set_max_level(max_level);
}
Expand Down