LogInterpreter.Abstractions is a .NET 8 library that provides fundamental interfaces and default implementations for processing log files using a pipeline-based architecture.
The library aims to provide a flexible and extensible framework for reading, processing, and writing log files in various formats. The pipeline-based approach enables chaining and reusing different processing steps.
Built on top of IEnumerable<T>, the pipeline architecture leverages lazy evaluation and streaming to efficiently process log files of any size. This design allows the library to handle massive datasets without loading entire files into memory, making it suitable for processing gigabyte-sized log files while maintaining a minimal memory footprint. Data flows through the pipeline element by element, enabling real-time processing and output generation even for extremely large log collections.
The fundamental interface for pipeline elements, enabling chained processing.
public interface IPipelineItem<TIn, out TOut> : IEnumerable<TOut>, IPipelineItem
{
string Name { get; }
IEnumerable<TIn> Input { get; set; }
}Unified representation of log entries. Supports:
- Timestamp (
Time) - Log level (
Level) - Message (
Message) - Raw data (
Raw) - Properties (
Properties) - SnTrace-specific fields (LineId, Category, ProgramFlowId, OpId, Status, Duration)
Log level definitions:
NotParsed- Not parsedCritical- CriticalError- ErrorWarning- WarningInformation- InformationTrace- TraceDebug- Debug
Configuration types:
Default- DefaultPath- File path
Used to mark properties that can be configured in pipeline elements.
[Configurable]
public string PropertyName { get; set; }
[Configurable(ConfigurationType.Path)]
public string FilePath { get; set; }Pre-built components available in the DefaultImplementations namespace:
LogSource- Default implementation of log sourceOneLineLogFileReader- Reading single-line log filesTwoLineLogFileReader- Reading two-line log formatTwoLineLogReader- Two-line log processor
CompactJsonLogParser- Processing compact JSON format logsTwoLineLogParser- Processing two-line format logs
Filter- Filtering log entriesTransformer- Transforming log entriesFormatter- Formatting log entries
ConsoleWriter- Writing to consoleFileWriter- Writing to file
Pipeline- Connecting and executing pipeline elements
LogEntry- Default implementation ofILogEntry
var pipeline = new Pipeline()
.AddItem(new LogSource { /* configuration */ })
.AddItem(new TwoLineLogParser())
.AddItem(new Filter { /* filtering conditions */ })
.AddItem(new Transformer { /* transformations */ })
.AddItem(new Formatter { /* formatting */ })
.AddItem(new ConsoleWriter());
pipeline.Run();public class MyCustomProcessor : IPipelineItem<ILogEntry, ILogEntry>
{
public string Name => "MyCustomProcessor";
public IEnumerable<ILogEntry> Input { get; set; }
[Configurable]
public string CustomProperty { get; set; }
public IEnumerator<ILogEntry> GetEnumerator()
{
foreach (var entry in Input)
{
// Custom processing
yield return entry;
}
}
}- .NET 8.0 or later
This project is available under the repository's license terms.