reactnative-client
  • @dormakaba/digital-reactnative-client
  • Getting started
  • Changelog
  • Concerns
    • App State
    • Global / Local Snacks
    • Forms
    • Navigation
    • i18n
    • rest api
  • Utils
    • formatters
    • EventEmitter
    • Logger
    • settings
    • validate
    • misc
Powered by GitBook
On this page
  1. Utils

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)
PreviousEventEmitterNextsettings

Last updated 6 years ago