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

3.6.1 • Public • Published

Tiny logger with a couple nice configurations.

included in @reatom/framework

Usage

All atoms and actions with names or without underscore logs automatically

import { connectLogger, createLogBatched } from '@reatom/logger'

connectLogger(ctx)

// OR

connectLogger(
  ctx,
  // optional configuration
  {
    // the length of the atom history (patches) to store
    history: 10,
    // `false` by default to made your logs short
    showCause: false,
    // `true` by default to made your logs clear
    skipUnnamed: true,
    // fine tuning :)
    skip: (patch: AtomCache) => false,
    // `createLogBatched` by default to not spam you a lot
    // you could pass regular `console.log` here
    log: createLogBatched(
      // optional configuration
      {
        // 500ms by default
        debounce: 500,
        // 5000ms by default, it helps to not stuck with WS and so on
        limit: 5000,
        // `toLocaleTimeString` by default
        getTimeStamp: () => new Date().toLocaleTimeString()

        log: console.log,
        // `true` by default to group logs by name
        shouldGroup: true,
      },
    ),
    // You could customize a logs group: `Reatom ${domain}N transactions`
    domain: '',
  },
)

Every log record includes a number in the start of the name to fix autosorting keys in a console.

Here is how it looks like (from this example):

logger console output

Readme

Keywords

none

Package Sidebar

Install

npm i @reatom/logger

Weekly Downloads

610

Version

3.6.1

License

MIT

Unpacked Size

59.6 kB

Total Files

10

Last publish

Collaborators

  • artalar