@obsidize/logger
Version:
A tiny javascript logging library
28 lines (27 loc) • 1.15 kB
TypeScript
import { LogEventSerializerDelegateConfig } from '../core/log-event-serializer';
import type { ConsoleLike, LogEventConsumer } from '../core/types';
/**
* Delegate to invoke some method a console-like target.
* Acts as a proxy for the global `window.console` object (or any other provided target).
*/
export type ConsoleOutputInvoker = (target: ConsoleLike, level: number, message: string, params: any[]) => void;
export interface ConsoleOutputConfig extends LogEventSerializerDelegateConfig {
/**
* The target to send serialized log events to
* @default cosnole
*/
target?: ConsoleLike;
/**
* The invocation handler for the provided console-like target.
*
* The default handler will narrow levels down to `LOG`, `WARN` and `ERROR`
* to maximize compatibility with different runtime environments.
*/
invoke?: ConsoleOutputInvoker;
}
/**
* Send events to a target console-like instance.
* @param config - optional customization config
* @returns an outlet function that can be invoked by a transport
*/
export declare function consoleOutput(config?: ConsoleOutputConfig): LogEventConsumer;