Releases: losandes/polyn-logger
fix: adds missing ArrayWriter properties
feat: adds es module support
What's Changed
- breaking: removes support for Logger by @losandes in #9
- feat: adds es module support by @losandes in #10
- fix: updates typedefs by @losandes in #8
Full Changelog: 0.5.3...0.6.0
breaking: removes support for Logger
A couple years ago, I moved on from using the orignal design of this libaray to inheriting from EventEmitter to follow a standard convention. This release is a breaking change that removes the legacy code, so only the LogEmitter will be supported moving forward.
fix: updates typedefs
The index.d.ts file was missing the listen function for ILogWriter and the LogEmitter class typedef wasn't carrying through the EventEmitter properties for some reason. This updates those typedefs and also adds new TypeScript tests to validate the changes.
fix: fixes an error where os is undefined
LogMetaFactory had a check for os being undefined but it throws in the
browser. This qualifies the check by addressing it on the dependencies
object.
chore: updates dependencies
Updates dependencies to:
- @polyn/blueprint 2.6.0
- @polyn/immutable 1.0.11
- @polyn/async-events 3.0.1
fix: Circumvents EventEmitter throw behavior
NodeJS' events has special behaviors with the 'error' event:
If an
EventEmitter
does not have at least one listener registered
for the 'error' event, and an 'error' event is emitted, the error is
thrown, a stack trace is printed, and the Node.js process exits.
This doesn't make sense for a log emitter that supports wildcards, or
patterns. This fix adds a noop listener to error to each emitter that is
created to circumvent the error throwing behavior.
feat: adds squash writer and event listeners
- Adds SquashWriter for flattening logs
- Adds
listen
to all writers, to make them compatible with the
LogEmitter
feat: adds try-with-metrics
We often need to track the performance (latency) of I/O bound
features (i.e. HTTP requests, database requests, API response
times), as well as compute bound features (i.e. algorithms).
Knowing the number of times a feature is used (counts), as well
as the volume it receives (gauges) can help us understand which
features are most important to our users, or if a feature is
actively being used, right now.
This adds tryWithMetrics to the LogEmitter, to simplify gathering
these kinds of metrics, so all you need to do is supply the writer to
get these metrics into your tracking system.
feat: adds new LogEmitter
Adds new LogEmitter
for simpler logging:
const { LogEmitter, writers, formatters } = require('@polyn/logger')
const log = new LogEmitter()
const logWriter = new writers.DevConsoleWriter({
formatter: new formatters.BlockFormatter()
})
const writeLog = async (meta, ...args) =>
logWriter.write(args && args.length === 1 ? args[0] : args, meta)
// subscribe to multiple categories
;['trace', 'debug', 'info', 'warn', 'error', 'fatal'].forEach(
(category) => log.on(category, writeLog)
)
log.emit('app_startup', 'info', { hello: 'world' })
Updates @polyn/async-events
Updates to use the latest version of @polyn/async-events
chore: removes unnecessary files
I noticed I was publishing things like screenshots. This release is after an npmignore was added to prune the package to what is necessary to install and use it.