@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
        };
    }
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 4.0.0
    16
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 4.0.0
    16
  • 1.3.1
    0
  • 1.3.0
    0
  • 1.2.0
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i @salesduck/format-logs

Weekly Downloads

16

Version

4.0.0

License

MIT

Unpacked Size

9.71 kB

Total Files

19

Last publish

Collaborators

  • webworkdeveloper