lib/util/log.js
function CruxLogger(_type, _level) {
  if (this instanceof CruxLogger) {
    Component.apply(this, arguments);
    this.name = 'log';
    var hasColors = this.config.colors;
    delete this.config.colors;
    if (!hasColors) {
      for (var i = 0; i < this.config.appenders.length; i++) {
        this.config.appenders[i].layout = {
          type: 'basic'
        }
      }
    }
    log4js.configure(this.config);
    this.__logger = log4js.getLogger();
    this.__logger.setLevel(this.config.level.toUpperCase());
    global['log'] = this.__logger;
  } else {  // In case we just called crux.Log(), we just want to return an instance of log4js
    this.__logger = log4js.getLogger(_type || 'default');
    if (typeof _level === 'string') {
      this.__logger.setLevel(_level);
    }
    return this.__logger;
  }
}
function CruxLogger(_type, _level) {
  if (this instanceof CruxLogger) {
    Component.apply(this, arguments);
    this.name = 'log';
    var hasColors = this.config.colors;
    delete this.config.colors;
    if (!hasColors) {
      for (var i = 0; i < this.config.appenders.length; i++) {
        this.config.appenders[i].layout = {
          type: 'basic'
        }
      }
    }
    log4js.configure(this.config);
    this.__logger = log4js.getLogger();
    this.__logger.setLevel(this.config.level.toUpperCase());
    global['log'] = this.__logger;
  } else {  // In case we just called crux.Log(), we just want to return an instance of log4js
    this.__logger = log4js.getLogger(_type || 'default');
    if (typeof _level === 'string') {
      this.__logger.setLevel(_level);
    }
    return this.__logger;
  }
}
function CruxLogger ( _type , _level ) { if ( this instanceof CruxLogger ) { Component . apply ( this , arguments ) ; this . name = 'log' ; var hasColors = this . config . colors ; delete this . config . colors ; if ( ! hasColors ) { for ( var i = 0 ; i < this . config . appenders . length ; i ++ ) { this . config . appenders [ i ] . layout = { type : 'basic' } } } log4js . configure ( this . config ) ; this . __logger = log4js . getLogger ( ) ; this . __logger . setLevel ( this . config . level . toUpperCase ( ) ) ; global [ 'log' ] = this . __logger ; } else { // In case we just called crux.Log(), we just want to return an instance of log4js this . __logger = log4js . getLogger ( _type || 'default' ) ; if ( typeof _level === 'string' ) { this . __logger . setLevel ( _level ) ; } return this . __logger ; } }
We may want to just attach log in the global scope.
We may want to just attach log in the global scope .