Browse files

The logger in early development stage

  • Loading branch information...
1 parent 85620f3 commit 6fdf8f5fe7a666a6ce99831b5c14019c04d4f2a5 Teodor Pripoae committed Jun 21, 2011
Showing with 44 additions and 4 deletions.
  1. +39 −3 lib/Logging/Log.js
  2. +5 −1 lib/Packagr.js
View
42 lib/Logging/Log.js
@@ -1,6 +1,42 @@
-var Log = Klass({
-
+var color = require("ansi-color").set;
+
+var COLORS = {
+ "info": "black",
+ "error": "red+bold",
+ "warn": "green",
+ "debug": "magenta",
+ "fatal": "black+yellow_bg+bold",
+}
+
+var Logger = Klass({
+ statics: {
+ logThis: function (str, type) {
+ var now = new Date();
+ //var formated_date = now.format("dddd, mmmm dS, yyyy, h:MM:ss TT");
+ console.log(now + " ", color(type.toUpperCase(), COLORS[type]), ": " + str);
+ },
+
+ info: function (str) {
+ this.logThis(str, 'info');
+ },
+
+ error: function (str) {
+ this.logThis(str, 'error');
+ },
+
+ debug: function (str) {
+ this.logThis(str, 'debug');
+ },
+
+ warn: function (str) {
+ this.logThis(str, 'warn');
+ },
+
+ fatal: function (str) {
+ this.logThis(str, 'fatal');
+ }
+ }
});
-module.exports = Log;
+module.exports = Logger;
View
6 lib/Packagr.js
@@ -13,6 +13,10 @@ var Packages = {
Router: {
'Base': './Router/Router'
},
+
+ Logging: {
+ 'Log': './Logging/Log'
+ },
TempDatabase: {
'BaseDB': './ModelPack/DatabaseConnection'
@@ -63,4 +67,4 @@ var Packagr = Klass({
});
-module.exports = Packagr;
+module.exports = Packagr;

0 comments on commit 6fdf8f5

Please sign in to comment.