1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
"use strict";
/**
* @fileOverview The logging system for papyrus is based on [http://pimterry.github.io/loglevel/](loglevel) and slightly decorated
* @module utils/logger
* @requires dcl
* @requires loglevel
*/
var dcl = require( "dcl" );
var log = require( 'loglevel' );
/**
* A logger class that you can mix into your classes to handle logging settings and state at an object level.
* See {@link utils/logger} for the members of this class
*
* @exports utils/logger.Logger
* @class
* @see utils/logger
*/
var Logger = dcl( null, /** @lends utils/logger.Logger# */{
declaredClass : "utils/Logger",
/**
* Turn off all logging. If you log something, it will not error, but will not do anything either
* and the cycles are minimal.
*
*/
silent : function () {
log.disableAll();
},
/**
* Turns on all logging levels
*
*/
all : function () {
log.enableAll();
},
/**
* Sets the logging level to one of `trace`, `debug`, `info`, `warn`, `error`.
* @param {string} lvl The level to set it to. Can be one of `trace`, `debug`, `info`, `warn`, `error`.
*
*/
level : function ( lvl ) {
if ( lvl.toLowerCase() === "none" ) {
log.disableAll();
} else {
log.setLevel( lvl );
}
},
/**
* Log a `trace` call
* @method
* @param {string} The value to log
*/
trace : log.trace,
/**
* Log a `debug` call
* @method
* @param {string} The value to log
*/
debug : log.debug,
/**
* Log a `info` call
* @method
* @param {string} The value to log
*/
info : log.info,
/**
* Log a `warn` call
* @method
* @param {string} The value to log
*/
warn : log.warn,
/**
* Log a `error` call
* @method
* @param {string} The value to log
*/
error : log.error
} );
module.exports = new Logger();
/**
* The system global, cross-platform logger
* @name utils/logger
* @static
* @type {utils/logger.Logger}
*/
module.exports.Logger = Logger;