Class: Logging

mmir. Logging

mmir.Logging

A Logger factory.
See:
Example
//use logger
 var Logger = mmir.require('mmirf/logger');
 var log = Logger.create('example');

 if(log.isVerbose()) log.debug('test');//will write the message to debug-console)
 log.error(new Error());//will write the error (including its stack) to error console)

 //example for setting up a logger in a requirejs-module:
 define(['mmirf/logger', 'module'], function(Logger, module){

   var logger = Logger.create(module);
   //this would create the same logger-object:
   //  Logger.create(module.id, module.config(module).logLevel);

   //use the logger instance...

   //create / retrieve the same logger
   var sameLogger = Logger.create(module.id);

 });

Members

_level

the (global) logging level 0: verbose 1: debug 2: info 3: warn 4: error 5: critical 6: disabled

Methods

create(loggerName, logLevel){mmir.tools.Logger}

Creates a mmir.tools.Logger instance. If a logger for loggerName already exists, the existing logger is returned (instead of creating a new one).
Name Type Description
loggerName String | Object optional If String: a name / ID for the logger that should be created / retrieved.
If Object: an requirejs module object, i.e. should contain properties id (String) which will set the loggerName, and a property/function config (Function) that returns an object with property logLevel (i.e. config().logLevel should be valid).
If omitted, the default logger will be returned.
logLevel String | LogLevel optional a name / ID for the logger that should be created / retrieved. If omitted, the default logger will be returned.
See:
Returns:
Type Description
mmir.tools.Logger the created (or retrieved) logger
Print debug message with default logger.
See:
Print error with default logger.
See:

getDefaultLogLevel(){Number}

Sets the default log-level.
See:
Returns:
Type Description
Number the log level: a number between 0 (verbose) and 6 (disabled)
Print information message with default logger.
See:
Print log output with default logger.
See:

setDefaultLogLevel(theLevel)

Sets the default log-level. This setting is used by loggers, that do not have a specific log-level set.
Name Type Description
theLevel String | Number if NUMBER, the log level as a number between 0 (verbose) and 6 (disabled) if STRING, the logging level as a string (see getLevel)
See:
Print verbose output with default logger.
See:
Print warning message with default logger.
See: