import { GlobalLoggerConfig, LoggerConfig, LoggerContext, RequestLoggerOptions, StringTemplate } from './types'; /** * ContextualLogger is responsible for managing context and prefixes on top of a standard logging library (Pino). * It abstracts how we handle those features by providing methods to add prefix and context in three levels, preserving * the following hierarchy: global > instance > execution */ export declare class ContextualLogger { private static pinoLogger; static globalConfig: GlobalLoggerConfig; private config; private context; private get resolvedPrefixTemplates(); constructor(config?: LoggerConfig); /** * This function uses environment and instance settings to generate * a name to easily identify the logs in Google Cloud. * @returns {string} logName name to be used in Google Cloud Logging */ static resolveGCloudLogName(): string; /** * Initializes Contextual Logger with global setup * @param config Logger config options - */ static initialize(config?: GlobalLoggerConfig): void; private static resolveTransportTargetOptions; private static assertLogger; /** * Log with 'info' level * @param message Message to log with info level. May contain placeholders like ${myPlaceholder} * @param context Context used to resolve placeholders in template. Has priority over local and global context */ info(message: StringTemplate, context?: LoggerContext): void; /** * Log with 'debug' level * @param message Message to log with info level. May contain placeholders like ${myPlaceholder} * @param context Context used to resolve placeholders in template. Has priority over local and global context */ debug(message: StringTemplate, context?: LoggerContext): void; /** * Log with 'warn' level * @param message Message to log with warn level. May contain placeholders like ${myPlaceholder} * @param context Context used to resolve placeholders in template. Has priority over local and global context */ warn(message: StringTemplate, context?: LoggerContext): void; /** * Log with 'trace' level * @param message Message to log with trace level. May contain placeholders like ${myPlaceholder} * @param context Context used to resolve placeholders in template. Has priority over local and global context */ trace(message: StringTemplate, context?: LoggerContext): void; /** * Log with 'error' level * @param message Message to log with log level. May contain placeholders like #{myPlaceholder} * @param context Context used to resolve placeholders in template. Has priority over local and global context * @param trace Stack trace to log */ error(message: any, context?: LoggerContext, trace?: string): void; /** * Log an HTTP Request and Response * @param options Options to log the request * @param options.context Context to append with the request * @param options.req Express Request * @param options.res Express Response * @param options.level Log level to use */ request(options: RequestLoggerOptions): void; /** * Adds string template to be logged by all logger instances in the entire service * @param templates Special string template - can be a function or plain string. The function will be able to build using the * context resolved for this request */ static appendGlobalPrefix(templates: StringTemplate | StringTemplate[]): void; /** * Adds string template to instance prefix which gets logged at beginning of each message. * Instance prefix is used only by this instance of ContextualLogger * @param templates Special string template - can be a function or plain string. The function will be able to build using the * context resolved for this request */ appendInstancePrefix(templates: StringTemplate | StringTemplate[]): void; /** * Adds string template to execution prefix which gets logged at beginning of each message * Execution prefix is used by other instances of ContextualLogger within the same execution chain (i.e. request) * @param template Special string template - can be a function or plain string. The function will be able to build using the * context resolved for this request */ appendExecutionPrefix(template: StringTemplate): void; /** * Adds values to instance context so that they can be used in string templates. * Instance context is used only by this instance of ContextualLogger, has priority over global context * @param additionalContext Object to merge into context */ setInstanceContext(additionalContext: LoggerContext): void; /** * Adds values to execution context so that they can be used in string templates * Execution context is used by other instances of ContextualLogger within the same execution chain (i.e. request) * @param additionalContext Object to merge into context */ setExecutionContext(additionalContext: LoggerContext): void; private get resolvedContext(); private resolvePrefix; private resolveMessageContext; private resolveMessage; }