# @types/logfmt

> TypeScript definitions for logfmt

Latest version **1.2.6** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/logfmt
pnpm add @types/logfmt
yarn add @types/logfmt
bun add @types/logfmt
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.2.6 |
| Published | 2023-11-07 |
| First published | 2019-06-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51449 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/logfmt
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/logfmt
- npm.io page: https://npm.io/package/@types/logfmt

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) *

## Recent versions

- 1.2.6 (latest) — 2023-11-07
- 1.2.4 (ts4.3) — 2023-08-30
- 1.2.3 (ts4.2) — 2023-02-07
- 1.2.2 (ts3.6) — 2021-07-08
- 1.2.1 (ts2.3) — 2019-08-19
- 1.2.0 (ts2.2) — 2019-06-18
- 1.2.5 — 2023-10-18

## 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](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/logfmt/index.d.ts)
````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: Tue, 07 Nov 2023 09:09:38 GMT
 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)

# Credits
These definitions were written by [Evan Broder](https://github.com/ebroder).

---
_Source: https://npm.io/package/@types/logfmt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
