Skip to main content

Crate log2src

Crate log2src 

Source
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:

  1. Create a LogMatcher
  2. Add one or more source roots
  3. Discover sources and extract the logging
  4. 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
CallSite
A resolved call site in the source tree, used in exception stack traces.
ExtractLogResult
The result of calling extract_log_statements() with the summary and errors.
ExtractLogSummary
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.
LogRefBuilder
Builder for LogRef. Use LogRefBuilder::build or LogRefBuilder::build_from_captures to construct one.
ProgressListener
ProgressTracker
A mechanism for tracking progress.
SourceRef
A log statement found in a source file, including its location and match pattern.
StackTrace
An exception stack trace embedded in a log message body.
StatementsInFile
Collection of log statements in a single source file
VariablePair
A variable expression and the value it held at the matched log call site.
WorkInfo

Enums§

LogError
ProgressUpdate
A notification of progress for subscribers to a ProgressTracker
SourceLanguage

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.