JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15730
  • Score
    100M100P100Q154609F
  • License MIT

TypeScript definitions for logfmt

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@types/logfmt) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Installation

    npm install --save @types/logfmt

    Summary

    This package contains type definitions for logfmt (https://github.com/csquared/node-logfmt#readme).

    Details

    Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/logfmt.

    index.d.ts

    /// <reference types="node" />
    
    import { IncomingMessage, ServerResponse } from "http";
    
    type HTTPHandler = (req: IncomingMessage, res: ServerResponse, next: (err?: any) => void) => any;
    
    interface WritableStream {
        write(data: string): void;
    }
    
    interface RequestLoggerOptions {
        immediate?: boolean | undefined;
        elapsed?: string | undefined;
    }
    type RequestLoggerFormatter = (req: IncomingMessage, res: ServerResponse) => object;
    
    interface RequestLogger {
        (options?: RequestLoggerOptions, formatter?: RequestLoggerFormatter): HTTPHandler;
        (formatter: RequestLoggerFormatter): HTTPHandler;
        commonFormatter: (req: IncomingMessage, res: ServerResponse) => {
            ip: string;
            time: string;
            method: string;
            path: string;
            "status": number;
            request_id?: string | undefined;
            content_length?: string | undefined;
            content_type?: string | undefined;
        };
    }
    
    interface Logfmt {
        stringify(data: object): string;
        parse(line: string): Partial<Record<string, string | boolean | null>>;
    
        log(data?: object, stream?: WritableStream): void;
        time(label?: string): Logfmt;
        namespace(data: object): Logfmt;
        error(err: Error, id?: string): void;
    
        streamParser(options?: { end?: boolean | undefined }): NodeJS.ReadWriteStream;
        streamStringify(options?: { delimiter?: string | undefined }): NodeJS.ReadWriteStream;
    
        bodyParser(options?: { contentType?: string | undefined }): HTTPHandler;
        bodyParserStream(options?: { contentType?: string | undefined }): HTTPHandler;
    
        requestLogger: RequestLogger;
    
        stream: WritableStream;
        maxErrorLines: number;
    }
    
    interface LogfmtStatic extends Logfmt {
        new(): Logfmt;
    }
    
    // logfmt copies its prototype onto the exported class, so you can both use it
    // directly as an instance of the class and as a constructor to instantiate new
    // instances.
    declare const logfmt: LogfmtStatic;
    
    export = logfmt;
    

    Additional Details

    • Last updated: Wed, 18 Oct 2023 05:47:08 GMT
    • Dependencies: @types/node

    Credits

    These definitions were written by Evan Broder.