2.1.7 • Published 6 months ago

@types/koa-bunyan-logger v2.1.7

Weekly downloads
1,850
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install --save @types/koa-bunyan-logger

Summary

This package contains type definitions for koa-bunyan-logger (https://github.com/koajs/bunyan-logger).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-bunyan-logger.

index.d.ts

// Type definitions for koa-bunyan-logger 2.1
// Project: https://github.com/koajs/bunyan-logger
// Definitions by: Steven McDowall <https://github.com/sjmcdowall>
//                 Jan Karlo Dela Cruz <https://github.com/jankdc>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

import { Middleware, Request, Response } from 'koa';

import Logger = require('bunyan');

declare function koaBunyanLogger(logger?: Logger): Middleware;

declare namespace koaBunyanLogger {
    interface RequestData {
        req: Request;
    }

    interface ResponseData {
        req: Request;
        res: Response;
    }

    interface RequestIdContextOptions {
        header?: string | undefined;
        prop?: string | undefined;
        requestProp?: string | undefined;
        field?: string | undefined;
    }

    interface RequestLoggerOptions {
        durationField?: string | undefined;
        levelFn?: ((status: number, err: Error) => string) | undefined;
        updateLogFields?: ((data: RequestData) => RequestData) | undefined;
        updateRequestLogFields?: ((requestData: RequestData) => RequestData) | undefined;
        updateResponseLogFields?: ((responseData: ResponseData) => ResponseData) | undefined;
        formatRequestMessage?: ((requestData: RequestData) => string) | undefined;
        formatResponseMessage?: ((responseData: ResponseData) => string) | undefined;
        ignorePath?: string[] | undefined;
    }

    interface TimeContextOptions {
        logLevel?: string | undefined;
        updateLogFields?: ((fields: any) => any) | undefined;
    }

    function requestLogger(opts?: RequestLoggerOptions): Middleware;
    function requestIdContext(opts?: RequestIdContextOptions): Middleware;
    function timeContext(opts?: TimeContextOptions): Middleware;
}

// Extend the Koa context to add the logger..
declare module 'koa' {
    interface BaseContext {
        log: Logger;
    }
}

export = koaBunyanLogger;

Additional Details

Credits

These definitions were written by Steven McDowall, and Jan Karlo Dela Cruz.

2.1.6

7 months ago

2.1.5

8 months ago

2.1.7

6 months ago

2.1.4

3 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.0

6 years ago