Types Reference
Complete TypeScript type definitions for logpare
Complete TypeScript type definitions for logpare.
Core Types
CompressionResult
Result object returned by compress() and compressText().
Fields:
templates- Array of discovered templates, sorted by occurrence count (descending)stats- Compression statisticsformatted- String representation in the requested format
Template
Represents a discovered log template with metadata.
Fields:
id- Unique template identifierpattern- Template pattern with<*>wildcards for variablesoccurrences- Number of log lines matching this templatesampleVariables- Sample values captured from variables (limited bymaxSamples)firstSeen- Line number where template was first seenlastSeen- Line number where template was last seenseverity- Severity level:'error','warning', or'info'urlSamples- Extracted hostnames from URLsfullUrlSamples- Complete URLs found in matching logsstatusCodeSamples- HTTP status codes (e.g.,[200, 404, 500])correlationIdSamples- Trace/request IDs for distributed tracingdurationSamples- Timing values (e.g.,["45ms", "1.5s"])isStackFrame- Whether this template represents a stack frame
CompressionStats
Statistics about the compression operation.
Fields:
inputLines- Number of input log lines processeduniqueTemplates- Number of unique templates discoveredcompressionRatio- Ratio of templates to input lines (0.0 to 1.0)estimatedTokenReduction- Estimated token savings as percentage (0-100)processingTimeMs- Time taken to process (milliseconds)
Options Types
CompressOptions
Options for compress() and compressText().
Fields:
format- Output format:'summary','detailed', or'json'(default:'summary')maxTemplates- Maximum templates in formatted output (default:50)- Plus all fields from
DrainOptions
DrainOptions
Configuration for the Drain algorithm.
Fields:
depth- Parse tree depth (default:4)simThreshold- Similarity threshold 0-1 (default:0.4)maxChildren- Max children per tree node (default:100)maxClusters- Max total templates (default:1000)maxSamples- Sample variables per template (default:3)preprocessing- Custom preprocessing strategyonProgress- Progress reporting callback
Preprocessing Types
ParsingStrategy
Strategy for preprocessing and tokenizing log lines.
Methods:
preprocess(line)- Preprocess a log line (mask variables, normalize, etc.)tokenize(line)- Split preprocessed line into tokensgetSimThreshold(depth)- Get similarity threshold for a given tree depth
Example:
Progress Types
ProgressCallback
Callback function for progress updates.
ProgressEvent
Progress event data.
Fields:
processedLines- Number of lines processed so fartotalLines- Total lines to process (if known)currentPhase- Current processing phasepercentComplete- Completion percentage 0-100 (only iftotalLinesknown)
ProcessingPhase
Current phase of the compression operation.
Enum Types
Severity
Log severity level.
Automatically detected from log content:
'error'- ERROR, FATAL, Exception, Failed, TypeError, etc.'warning'- WARN, Warning, Deprecated, [Violation]'info'- Default for other logs
OutputFormat
Output format for compression results.
'summary'- Compact template list with frequencies'detailed'- Full templates with all metadata'json'- Machine-readable JSON
Constants
WILDCARD
The wildcard placeholder used in templates.
Example:
DEFAULT_PATTERNS
Built-in regex patterns for common log variables.
Example:
SEVERITY_PATTERNS
Regex patterns for severity detection.
STACK_FRAME_PATTERNS
Regex patterns for stack frame detection.
Utility Functions
detectSeverity()
Detect severity level from a log line.
Example:
isStackFrame()
Check if a line is a stack frame.
Example:
extractUrls()
Extract URLs/hostnames from a log line.
Example:
defineStrategy()
Create a custom preprocessing strategy.
Example: