Level class used to describe logging levels. The levels determine what types of events are logged to the appenders for example the if Level.ALL is used then all event will be logged, however if Level.INFO was used then ONLY INFO, WARN, ERROR, and FATAL events will be logged. To turn off logging for a logger use Level.OFF.

Not typically instantiated directly, but through staticly defined levels

Example
//Levels in ascending order
comb.logging.Level.ALL
comb.logging.Level.DEBUG
comb.logging.Level.TRACE
comb.logging.Level.INFO
comb.logging.Level.WARN
comb.logging.Level.ERROR
comb.logging.Level.FATAL
comb.logging.Level.OFF

//or
Level.getLevel("INFO");
            
Static Properties
PropertyTypeDefault ValueDescription
ALLpropertynull

Level to allow logging of all events.

DEBUGpropertynull

Logs only events debug or greater.

ERRORpropertynull

Error or fatal events

FATALpropertynull

Only fatal events

INFOpropertynull

Only info, or error related events

OFFpropertynull

No events will be logged.

TRACEpropertynull

Like debug but provides a finer level of detail

WARNpropertynull

Only warn or error related events

Instance Properties
PropertyTypeDefault ValueDescription
levelNumber

the numerical representation of this level.

nameString

the name of level.

Constructor

Defined logging/level.js

addLevel Static Function Public


Defined logging/level.js

Adds a new level to the Level object.

Example
logger = Logger.getLogger("my.logger");

//create the custom level
Level.addLevel("custom_Level", 20);

//now set the level on a logger
logger.level = Level.CUSTOM_LEVEL;
        
Arguments Returns Source
function (label,level){
   var ret;
   if (base.isString(label) && base.isNumber(level)) {
       label = label.toUpperCase();
       LEVELS_REVERSE[level] = label;
       LEVELS[label] = level;
       ret = (this[label] = new Level(level, label));
   }
   return ret;
           
}
    

toLevel Static Function Public


Defined logging/level.js

Converts a numerical or string representation of a level, if a default level is provided, then if a level cannot be determined then the default level is used.

Arguments Returns Source
function (level,defaultLevel){
   var ret = null;
   var args = base.argsToArray(arguments);
   if (args.length === 1) {
       level = args[0];
       if (base.isNumber(level)) {
           var strLevel = LEVELS_REVERSE[level];
           ret = Level[strLevel];
       } else if (base.isString(level)) {
           ret = Level[level.toUpperCase()];
       } else {
           ret = level;
       }
   } else {
       ret = (Level.toLevel(args[0]) || args[1]);
   }
   return ret;
           
}
    

equals Function Public


Defined logging/level.js

Determing if this level is equal to another level based off of the numerical rank.

Arguments Returns Source
function (level){
   return level.level === this.level;
           
}
    

isGreaterOrEqualToo Function Public


Defined logging/level.js

Determing if this level is >= another level

Arguments Returns Source
function (level){
   var ret = false;
   if (level && base.isNumber(level.level)) {
       if (this.level >= level.level) {
           ret = true;
       }
   }
   return ret;
           
}
    

License

MIT https://github.com/C2FO/comb/raw/master/LICENSE

Meta