@botmesh/core - v2.0.0-alpha.2
    Preparing search index...

    Interface LoggerLike

    The logger contract of the core and of every @botmesh/* package (BotConfig.logger, store and provider logger options). pino satisfies it as is; console and any object with these four methods work too.

    Calling convention (pino style). Every call the packages make has one of two shapes:

    • logger.warn('message'): a plain message.
    • logger.warn({ err, chatId }, 'message'): a context object FIRST, then the message. An error goes under the err key (pino serializes its stack there).

    The packages never pass a message first and an object after it (pino would drop that object), and never rely on printf placeholders. A custom logger should therefore treat a leading object as structured context and the following string as the message. child(bindings) is optional: without it, the bindings ({ module: 'store' }) are dropped.

    const logger: LoggerLike = {
    debug: () => {},
    info: (obj, msg) => console.info(msg ?? obj, typeof obj === 'object' ? obj : ''),
    warn: (obj, msg) => console.warn(msg ?? obj, typeof obj === 'object' ? obj : ''),
    error: (obj, msg) => console.error(msg ?? obj, typeof obj === 'object' ? obj : ''),
    }
    interface LoggerLike {
        debug(...a: unknown[]): void;
        info(...a: unknown[]): void;
        warn(...a: unknown[]): void;
        error(...a: unknown[]): void;
        child?(bindings: Record<string, unknown>): LoggerLike;
    }
    Index