@salesduck/format-logs
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

Format

Abstraction for representing log data in a specific format

Setup

Install package

yarn add @salesduck/format

Usage

You can develop a new format

You just need to create a new field where you can save the formatted data that will be transferred to the transport

import { LogMessage, FormatterLogMessage, MESSAGE } from '@salesduck/symbols-logs';
import { Formatter } from '@salesduck/format-logs';

export class MyFormat extends Formatter {
    format(log: LogMessage): FormatterLogMessage {
        return {
            ...log,
            [MESSAGE]: log.message.toUpperCase()
        };
    }
}

You can specify log type

type MyLog = { orderId?: string }

export class MyFormat extends Formatter {
    format(log: LogMessage<MyLog>): FormatterLogMessage {
        return {
            ...log,
            [MESSAGE]: log.message.toUpperCase() + log.orderId
        };
    }
}

/@salesduck/format-logs/

    Package Sidebar

    Install

    npm i @salesduck/format-logs

    Weekly Downloads

    10

    Version

    4.0.0

    License

    MIT

    Unpacked Size

    9.71 kB

    Total Files

    19

    Last publish

    Collaborators

    • webworkdeveloper