- Cobalt.Console = Class(Cobalt, 'Console')({
- prototype : {
- from : "Generic Cobalt Logger",
- version : "0.1.0",
- currentIndent : 0,
- indentSize : 2,
- loggers : [],
- separatorLength : 120,
- currentColor : "black",
-
- // Initialize instance of cobalt console
- // and extend configuration.
- init : function (config) {
- var co = this,
- property;
-
- if (config) {
- for (property in config) {
- co[property] = config[property];
- }
- }
- },
-
- addLogger : function (logger) {
- this.loggers.push(logger);
- },
-
- removeLogger : function (logger) {
- var index;
-
- index = this.loggers.indexOf(logger);
- this.loggers.splice(index, 1);
- },
-
- // Builds a Cobalt Log Object
- buildLog : function (item, level) {
- var co = this, oldItem, logObject = {};
-
- if (!item._cobaltLog) {
- logObject.message = item;
- logObject._cobaltLog = true;
- logObject._from = co.from;
- logObject._level = item._level || level || 7;
- logObject._levelString = co._levelString(item._level);
- logObject._version = co.version;
- logObject._timestamp = co.now();
- logObject._indentLevel = co.currentIndent;
- logObject._color = co.currentColor;
- return logObject;
- }