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
Property | Type | Default Value | Description |
ALL | property | null | Level to allow logging of all events. |
DEBUG | property | null | Logs only events debug or greater. |
ERROR | property | null | Error or fatal events |
FATAL | property | null | Only fatal events |
INFO | property | null | Only info, or error related events |
OFF | property | null | No events will be logged. |
TRACE | property | null | Like debug but provides a finer level of detail |
WARN | property | null | Only warn or error related events |
Property | Type | Default Value | Description |
level | Number | the numerical representation of this level. | |
name | String | the name of level. | |
Adds a new level to the Level object.
Examplelogger = 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
the label of the level, Note: the label will be coverted to uppercase.
the level of the level
undefined|comb.logging.Level
the level that was created.
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; }
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.
Argumentsthe level to try to convert
default level to use if one cannot be determined,
comb.logging.Level|null
returns a level if one can be determined null otherwise.
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; }
Determing if this level is equal to another level based off of the numerical rank.
Argumentsthe level to compare
Boolean
true if this is equal to that false otherwise.
function (level){ return level.level === this.level; }
Determing if this level is >= another level
Argumentsthe level to test against
Boolean
true if this is >= false otherwise.
function (level){ var ret = false; if (level && base.isNumber(level.level)) { if (this.level >= level.level) { ret = true; } } return ret; }
MIT https://github.com/C2FO/comb/raw/master/LICENSE
git clone git://github.com/C2FO/comb.git