Skip to content

Releases: structured-log/structured-log

v0.2.0

26 Sep 20:32
Compare
Choose a tag to compare

Time for another small release.

  • Enricher functions now receive a copy of the event properties as an argument, enabling conditional masking of sensitive information (thanks @lyallaward)
  • Verbose and Debug levels now work for ConsoleSink in Node.js (fixes #47, thanks @charandas)
  • BatchedSink has been implemented to add batching capabilities for existing or new sinks (#34)
  • Replaced Mocha+Istanbul with Jest for running unit tests and generating coverage reports

v0.1.0

17 Jan 19:50
Compare
Choose a tag to compare

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
  • fatal has been added as an additional logging level, sitting one level higher than error
  • The minimum logging level can now be controlled dynamically using the DynamicLevelSwitch class (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.