Logger

Basic logger. A logger that lets you extend implementations as needed. Eg. for using an external logging service.

import { Logger } from '@dormakaba/digital-reactnative-client';

// functions like used in console.log
Logger.log('msg', arg1, arg2, ...);
Logger.warn('msg', arg1, arg2, ...);
Logger.error('msg', arg1, arg2, ...);
Logger.critical('msg', arg1, arg2, ...);

// override the logger implementation
const myLogger = {
  type: 'logger',
  log(args) { this._output('log', args); },
  warn(args) { this._output('warn', args); },
  error(args) { this._output('error', args); },
  _output(type, args) { if (console && console[type]) console[type](...Array.prototype.slice.call(args)); },
};

Logger.init(myLogger)

Last updated