@skypilot/logger
A utility for flexibly tracking & displaying events
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