2.1.0 • Published 8 months ago

@loglayer/plugin-sprintf v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Sprintf Plugin for LogLayer

NPM Version NPM Downloads TypeScript

The sprintf plugin for loglayer provides printf-style string formatting support using sprintf-js.

It allows you to format your log messages using familiar printf-style placeholders if a transport does not support this behavior.

Disclaimer

  • LogLayer does not allow passing items that are not strings, booleans, or numbers into message methods like info, error, etc, and would recommend that only string / boolean / number specifiers be used.

Installation

npm install @loglayer/plugin-sprintf

Usage

import { LogLayer, ConsoleTransport } from 'loglayer'
import { sprintfPlugin } from '@loglayer/plugin-sprintf'

const log = new LogLayer({
  transport: new ConsoleTransport({
    logger: console
  }),
  plugins: [
    sprintfPlugin()
  ]
})

// Example usage
log.info("Hello %s!", "world")
// Output: Hello world!

log.info("Number: %d", 42)
// Output: Number: 42

Documentation

For more details, visit https://loglayer.dev/plugins/sprintf

2.1.0

8 months ago

2.0.4

10 months ago

2.0.3

10 months ago

2.0.2

10 months ago

2.0.1

11 months ago

2.0.0

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago