@kinvolk/headlamp-plugin
Version:
The needed infrastructure for building Headlamp plugins.
28 lines (27 loc) • 1.17 kB
TypeScript
/** Supported log severity levels. */
export type LogSeverity = 'error' | 'warn' | 'info' | 'debug';
/** All severity levels in descending order of importance. */
export declare const ALL_SEVERITIES: LogSeverity[];
/**
* Detect the severity level of a single log line.
*
* Supports common structured and unstructured log formats:
* - JSON fields: "level":"error", "severity":"warning"
* - Key-value pairs: level=error, severity=ERROR
* - Bracketed tokens: [ERROR], [WARN], [WARNING], [INFO], [DEBUG]
* - Space-delimited tokens (Go/Python): ERROR , WARNING , INFO , DEBUG
*
* @returns The detected severity, or null if none is found.
*/
export declare function detectSeverity(line: string): LogSeverity | null;
/**
* Filter an array of log lines by the selected severity levels.
*
* Lines with no detectable severity are always included to avoid
* hiding plain-text or structureless output.
*
* @param logs - The full array of log lines.
* @param selectedSeverities - The severity levels to keep.
* @returns The filtered array of log lines.
*/
export declare function filterLogsBySeverity(logs: string[], selectedSeverities: LogSeverity[]): string[];