UNPKG

@loglayer/plugin

Version:

Base plugin used to implement plugins for loglayer.

61 lines (59 loc) 4.14 kB
import { ILogLayer, ILogLayer as ILogLayer$1, LogLayerPlugin, LogLayerPluginParams, LogLevel, LogLevelType, LogLevelType as LogLevelType$1, PluginBeforeDataOutParams, PluginBeforeDataOutParams as PluginBeforeDataOutParams$1, PluginBeforeMessageOutParams, PluginBeforeMessageOutParams as PluginBeforeMessageOutParams$1, PluginShouldSendToLoggerParams, PluginShouldSendToLoggerParams as PluginShouldSendToLoggerParams$1, PluginTransformLogLevelParams, PluginTransformLogLevelParams as PluginTransformLogLevelParams$1 } from "@loglayer/shared"; //#region src/types.d.ts /** * Callback function for transforming the log level after onBeforeDataOut and onBeforeMessageOut but before shouldSendToLogger. * * @see {@link https://loglayer.dev/plugins/creating-plugins.html#transformloglevel | transformLogLevel Docs} */ type PluginTransformLogLevelFn = (params: PluginTransformLogLevelParams$1, loglayer: ILogLayer$1) => LogLevelType$1 | null | undefined | false; /** * Callback function for transforming the data object containing metadata, context, and error information before it's * sent to the logging library before it is sent to the transport library. * * @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforedataout | onBeforeDataOut Docs} */ type PluginBeforeDataOutFn = (params: PluginBeforeDataOutParams$1, loglayer: ILogLayer$1) => Record<string, any> | null | undefined; /** * Callback function for determining if the message should be sent to the transport library. * * @see {@link https://loglayer.dev/plugins/creating-plugins.html#shouldsendtologger | shouldSendToLogger Docs} */ type PluginShouldSendToLoggerFn = (params: PluginShouldSendToLoggerParams$1, loglayer: ILogLayer$1) => boolean; /** * Callback function for transforming the message data before it is sent to the transport library. * * @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforemessageout | onBeforeMessageOut Docs} */ type PluginBeforeMessageOutFn = (params: PluginBeforeMessageOutParams$1, loglayer: ILogLayer$1) => any[]; /** * Callback function for when `withMetadata()` or `metadataOnly()` is called. * * @see {@link https://loglayer.dev/plugins/creating-plugins.html#onmetadatacalled | onMetadataCalled Docs} */ type PluginOnMetadataCalledFn = (metadata: Record<string, any>, loglayer: ILogLayer$1) => Record<string, any> | null | undefined; /** * Callback function for when `withContext()` is called * * @see {@link https://loglayer.dev/plugins/creating-plugins.html#oncontextcalled | onContextCalled Docs} */ type PluginOnContextCalledFn = (context: Record<string, any>, loglayer: ILogLayer$1) => Record<string, any> | null | undefined; /** * List of plugin callbacks that can be called by the plugin manager. * * @see {@link https://loglayer.dev/plugins/creating-plugins.html#transformloglevel | transformLogLevel Docs} * @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforedataout | onBeforeDataOut Docs} * @see {@link https://loglayer.dev/plugins/creating-plugins.html#shouldsendtologger | shouldSendToLogger Docs} * @see {@link https://loglayer.dev/plugins/creating-plugins.html#onmetadatacalled | onMetadataCalled Docs} * @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforemessageout | onBeforeMessageOut Docs} * @see {@link https://loglayer.dev/plugins/creating-plugins.html#oncontextcalled | onContextCalled Docs} */ declare enum PluginCallbackType { transformLogLevel = "transformLogLevel", onBeforeDataOut = "onBeforeDataOut", shouldSendToLogger = "shouldSendToLogger", onMetadataCalled = "onMetadataCalled", onBeforeMessageOut = "onBeforeMessageOut", onContextCalled = "onContextCalled", } //#endregion export { type ILogLayer, type LogLayerPlugin, type LogLayerPluginParams, LogLevel, type LogLevelType, PluginBeforeDataOutFn, type PluginBeforeDataOutParams, PluginBeforeMessageOutFn, type PluginBeforeMessageOutParams, PluginCallbackType, PluginOnContextCalledFn, PluginOnMetadataCalledFn, PluginShouldSendToLoggerFn, type PluginShouldSendToLoggerParams, PluginTransformLogLevelFn, type PluginTransformLogLevelParams };