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

0.2.0-next.0 • Public • Published

@skypilot/logger

A utility for flexibly tracking & displaying events


npm stable stable build npm next next build downloads license: ISC

How to install

yarn add @skypilot/logger

How to use

Add events:

const log = new EventLog()
log.debug('A debug event')
log.info('An info event')
log.warn('Something you should know')
log.error('Uh-oh')

List event messages:

log.getMessages()
Debug: A debug event
Info: An info event
Warn: Something you should know
Error: Uh-oh

List one level of messages:

log.getMessages('error')
Error: Uh-oh

Or access the messages directly:

console.log(log.messages.error)
Uh-oh

Check for errors:

console.log(log.hasErrors)
true

Add data to every event:

const log = new EventLog({ initialData: { key: 'Always added' } })
log.info('Event with data', { newKey: 'Added for one event' })
log.getEvents()
[
  {
    "level": "info",
    "message": "Event with data",
    "data": { "key": "Always added", "newKey":  "Added for one event" }
  }
]

More to be added

Package Sidebar

Install

npm i @skypilot/logger

Weekly Downloads

1

Version

0.2.0-next.0

License

MIT

Unpacked Size

17.3 kB

Total Files

10

Last publish

Collaborators

  • williamthorsen