@fethcat/logger
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Logger

Usage

Install package:

pnpm add @fethcat/logger

Create logger with message and options:

import { Logger, LoggerOptions } from '@fethcat/logger'

const logger = Logger.create<'my_action_message'>(
  'instanceId',
  { silent: false },
  { app: 'app', env: 'env', version: 'version' },
)
logger.info('my_app_message', { meta: 'value' })

Actions

import { Logger, LoggerOptions } from '@fethcat/logger'

const logger = Logger.create<'my_action_message'>(
  'instanceId',
  { silent: false },
  { app: 'app', env: 'env', version: 'version' },
)

const { success, failure } = logger.start('my_action_message', { meta: 'value' }) // Logs "my_action_message" with meta { meta: 'value' }

try {
  // Do something
  success({ another: 'meta' }) // Logs "my_action_message_success" with meta { meta: 'value', another: 'meta' }
} catch (error) {
  failure(error, { another: 'meta' }) // Logs "my_action_message_failure" with meta { meta: 'value', another: 'meta', error }
}

Options

The following options are available:

Name Type Default value Description
silent boolean false Whether the logger should be silent or not

Readme

Keywords

none

Package Sidebar

Install

npm i @fethcat/logger

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

16.1 kB

Total Files

16

Last publish

Collaborators

  • fethcat