import { LeveledLogEntry, LogEntry } from '.' /** * Log entry without scope variable */ export type LogEntryWithoutScope = Exclude, { scope: string }> /** * Leveled log entry without scope variable */ export type LeveledLogEntryWithoutScope = Exclude, { scope: string }> /** * A logger instance with predefined scopes */ export interface ScopedLogger { /** * Adds a custom log entry */ addEntry: (entry: LeveledLogEntryWithoutScope, isVerbose?: boolean) => Promise /** * Adds a Verbose log entry. Verbose is the noisiest level, rarely (if ever) enabled for a production app. */ verbose: (entry: LogEntryWithoutScope) => Promise /** * Adds a debug log entry. Debug is used for internal system events that are not necessarily observable from the outside, but useful when determining how something happened. */ debug: (entry: LogEntryWithoutScope) => Promise /** * Adds an Information log entry. Information events describe things happening in the system that correspond to its responsibilities and functions. Generally these are the observable actions the system can perform. */ information: (entry: LogEntryWithoutScope) => Promise /** * Adds a Warning log entry. When service is degraded, endangered, or may be behaving outside of its expected parameters, Warning level events are used. */ warning: (entry: LogEntryWithoutScope) => Promise /** * Adds an Error log entry. When functionality is unavailable or expectations broken, an Error event is used. */ error: (entry: LogEntryWithoutScope) => Promise /** * Adds a Fatal log entry. The most critical level, Fatal events demand immediate attention. */ fatal: (entry: LogEntryWithoutScope) => Promise } /** * Interface that defines a Logger implementation */ export interface Logger { /** * Adds a custom log entry */ addEntry: (entry: LeveledLogEntry, isVerbose?: boolean) => Promise /** * Adds a Verbose log entry. Verbose is the noisiest level, rarely (if ever) enabled for a production app. */ verbose: (entry: LogEntry) => Promise /** * Adds a debug log entry. Debug is used for internal system events that are not necessarily observable from the outside, but useful when determining how something happened. */ debug: (entry: LogEntry) => Promise /** * Adds an Information log entry. Information events describe things happening in the system that correspond to its responsibilities and functions. Generally these are the observable actions the system can perform. */ information: (entry: LogEntry) => Promise /** * Adds a Warning log entry. When service is degraded, endangered, or may be behaving outside of its expected parameters, Warning level events are used. */ warning: (entry: LogEntry) => Promise /** * Adds an Error log entry. When functionality is unavailable or expectations broken, an Error event is used. */ error: (entry: LogEntry) => Promise /** * Adds a Fatal log entry. The most critical level, Fatal events demand immediate attention. */ fatal: (entry: LogEntry) => Promise /** * Returns an object that contains shortcuts to the original logger that contains the provided scope. * * usage example: * ```ts * const scopedLogger = myLogger.withScope("myLogScope") * * scopedLogger.information({message: "foo"}) // will add an information entry with the provided scope * ``` */ withScope: (scope: string) => ScopedLogger }