- 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 (typeof item === "undefined" || item === null || !item._cobaltLog) {
- logObject.message = item;
- logObject._cobaltLog = true;
- logObject._from = co.from;
- logObject._level = level || 6;
- logObject._levelString = co._levelString(logObject._level);
- logObject._version = co.version;
- logObject._timestamp = co.now();
- logObject._indentLevel = co.currentIndent;
- logObject._color = co.currentColor;
- logObject._separator = false;
- return logObject;
- }