The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/rocketchat-logger
Rodrigo Nascimento a2b4564d47 Add ESLint rules `prefer-template` and `template-curly-spacing` (#6456) 9 years ago
..
client Change all instances of Meteor.Collection for Mongo.Collection (#6410) 9 years ago
README.md Create a README of Logger 10 years ago
ansispan.js Add ESLint rules `prefer-template` and `template-curly-spacing` (#6456) 9 years ago
logger.coffee Change all instances of Meteor.Collection for Mongo.Collection (#6410) 9 years ago
package.js Change all instances of Meteor.Collection for Mongo.Collection (#6410) 9 years ago
server.coffee Fix message typo. 10 years ago

README.md

Logger

Constructor

new Logger(name, options);

options

  • sections: An object of sections
  • methods: An object of new methods

Example

const logger = new Logger('LDAP', {
  sections: {
    connection: 'Connection',
    bind: 'Bind',
    search: 'Search',
    auth: 'Auth'
  }
});

Usage

logger.info('connecting');
// LDAP ➔ info connecting

logger.connection.info('connecting');
// LDAP ➔ Connection.info connecting

Sections have all avaliable methods methods, the default methods are:

debug:
  name: 'debug'
  color: 'blue'
  level: 2
log:
  name: 'info'
  color: 'blue'
  level: 1
info:
  name: 'info'
  color: 'blue'
  level: 1
success:
  name: 'info'
  color: 'green'
  level: 1
warn:
  name: 'warn'
  color: 'magenta'
  level: 1
error:
  name: 'error'
  color: 'red'
  level: 0

The method error will always log the file and line of method execution

LoggerManager (singleton)

You can enable, disable, or set the log level for all logs here. You can show the origin package and file/line from all logs here.

LoggerManager.enabled = false;
LoggerManager.showPackage = false;
LoggerManager.showFileAndLine = false;
LoggerManager.logLevel = 0;

The LoggerManager starts disabled, you should enable in some point, if you want to print all logs queued while disabled use:

LoggerManager.enable(true);