      1 var define = require("../../define.js").define, base = require("../../base"), string = base.string, style = string.style, format = string.format, Appender = require("./appender"), Level = require("../level");
      2
      3 /**
      4  * @class Appends messages to the console.
      5  *
      6  * @name ConsoleAppender
      7  * @augments comb.logging.appenders.Appender
      8  * @memberOf comb.logging.appenders
      9  */
     10 exports = module.exports = define(Appender, {
     11 			instance : {
     12
     13 				constructor : function(options){
     14 					options = options || {};
     15 					!options.name && (options.name = "consoleAppender");
     16 					this._super(arguments, [options]);
     17 				},
     18
     19 				append : function(event) {
     20 					if (this._canAppend(event)) {
     21 						var message = format(this.__pattern, event);
     22 						var level = event.level;
     23 						if (Level.ERROR.equals(level) || Level.FATAL.equals(level)) {
     24 							console.log(style(message, "red"));
     25 						} else if(Level.WARN.equals(level)){
     26 							 console.log(style(message, "yellow"));
     27 						}else if (Level.DEBUG.equals(level)) {
     28 							console.log(style(message, "magenta"));
     29 						} else if (Level.TRACE.equals(level)) {
     30 							console.log(style(message, "cyan"));
     31 						} else {
     32 							console.log(message);
     33 						}
     34 					}
     35 				}
     36 			}
     37 		});