Expand description
log2src maps between generated logs and source code locations.
§Stability
This crate is evolving. Prefer types and methods documented as part of the primary workflow. Other exposed types may become internal in future releases.
§Quick Start
The typical flow is:
- Create a LogMatcher
- Add one or more source roots
- Discover sources and extract the logging
- Build a LogRef from log input and attempt to match it
§Example
use log2src::{LogMatcher, LogRefBuilder};
use std::path::Path;
let mut matcher = LogMatcher::new();
matcher.add_root(Path::new("./src")).unwrap();
matcher.discover_sources();
let _summary = matcher.extract_log_statements();
let log_ref = LogRefBuilder::new()
.with_body(Some("hello from logs"))
.build("hello from logs");
let _mapping = matcher.match_log_statement(&log_ref);Structs§
- Cache
- Handle for the source tree cache
- Call
Site - A resolved call site in the source tree, used in exception stack traces.
- Extract
LogResult - The result of calling extract_log_statements() with the summary and errors.
- Extract
LogSummary - A summary of the work done by extract_log_statements(). Useful for knowing if there were any changes that need to be saved to the cache.
- LogDetails
- Structured fields parsed from a log line by a
LogFormat. - LogFormat
- LogMapping
- The result of matching a log line to a source statement.
- LogMatcher
- Maps log lines to source statements discovered from one or more source roots.
- LogRef
- A parsed log line, optionally with structured details extracted by a
LogFormat. - LogRef
Builder - Builder for
LogRef. UseLogRefBuilder::buildorLogRefBuilder::build_from_capturesto construct one. - Progress
Listener - Progress
Tracker - A mechanism for tracking progress.
- Source
Ref - A log statement found in a source file, including its location and match pattern.
- Stack
Trace - An exception stack trace embedded in a log message body.
- Statements
InFile - Collection of log statements in a single source file
- Variable
Pair - A variable expression and the value it held at the matched log call site.
- Work
Info
Enums§
- LogError
- Progress
Update - A notification of progress for subscribers to a ProgressTracker
- Source
Language
Functions§
- extract_
variables - Extract variable name/value pairs by matching the log line against the source statement’s pattern.
- set_
tracker_ once - Sets the global progress tracker for the lifetime of the program.