v0.1.0
It's been a while since the last release, but here it is! This release doesn't add a whole lot of functionality, but it does bring with it a couple of noteworthy changes to get the ball rolling again.
- The codebase has been rewritten from the bottom up using TypeScript (#35)
- The documentation has also been rewritten to accurately reflect the new API surface
fatalhas been added as an additional logging level, sitting one level higher thanerror- The minimum logging level can now be controlled dynamically using the
DynamicLevelSwitchclass (as requested in #33) - Error objects can be included in messages again (#36)
Migrating from v0.0.18
Promises are now used internally, so a Promise polyfill is required for environments without native support.
Additioanlly, only ConsoleSink is included by default, and it is no longer a separate module. The other sinks that were previously included (FileSink, StdioSink and TerminalSink) have not been rewritten yet, but they can still be used by adding a wrapper that converts events to the old event format. Note that they are not included with the v0.1.0 package, so they would need to be manually extracted from v0.0.18 to continue using them.
function LegacySinkWrapper(legacySink) {
this.emit = function emit(events) {
legacySink.emit(events.map(function (e) {
return Object.assign({}, e, {
level: structuredLog.LogEventLevel[e.level]
.toUpperCase()
.replace('WARNING', 'WARN')
.replace('INFORMATION', 'INFO'),
timestamp: new Date(e.timestamp),
renderedMessage: function () { return e.messageTemplate.render(); }
});
}));
}
}Which can then be used to support the old sinks in the new pipeline:
const logger = structuredLog.configure()
.writeTo(new LegacySinkWrapper(consoleSink()))
.writeTo(new LegacySinkWrapper(stdioSink()))
.writeTo(new LegacySinkWrapper(terminalSink()))
.writeTo(new LegacySinkWrapper(fileSink('C:\\temp\\structuredlog.txt')))
.create();This is also true for 3rd party sinks that targeted v0.0.18.