UNPKG

@obsidize/logger

Version:
56 lines (55 loc) 1.89 kB
import type { LogEventFilterPredicate } from './types'; /** * Base class for other constructs that need to filter log events. * * Sub-classes of this will use the `test` delegate to determine * if log events are considered valid and/or acceptable. */ export declare class LogEventGuard { static readonly FILTER_ACCEPT_ALL: LogEventFilterPredicate; static readonly FILTER_BLOCK_ALL: LogEventFilterPredicate; /** * Predicate that will be used for log event validation. */ test: LogEventFilterPredicate; /** * Accept all tested events. * * Mutually exclusive operation to `setCustomFilter`; if a * custom filter was set before calling this, it will be cleared. * * @returns `this` for operation chaining. */ enable(): this; /** * Reject all tested events. * * Mutually exclusive operation to `setCustomFilter`; if a * custom filter was set before calling this, it will be cleared. * * @returns `this` for operation chaining. */ disable(): this; /** * Applies a custom filter for log event validation. * * This should not be used in conjuction with enable/disable * methods, as they will overwrite the given custom filter. * * @param filter - the custom filter to use for validation * @returns `this` for operation chaining. */ setCustomFilter(filter: LogEventFilterPredicate): this; /** * Convenience for setting enabled state based on a flag. * * Mutually exclusive operation to `setCustomFilter`; if a * custom filter was set before calling this, it will be cleared. * * @param enabled - the filter state to use, e.g. * `true` to accept all events, or * `false` to reject all events. * @returns `this` for operation chaining. */ setEnabled(enabled: boolean): this; }