Permalink
Browse files

Using factory structure, add ansi codes for colouring and manipulatin…

…g strings
  • Loading branch information...
1 parent 40f7130 commit f4e4d923b1a075a83b1f8445510de2225df5f1d9 @fadrizul committed Mar 27, 2012
Showing with 116 additions and 2 deletions.
  1. +3 −0 README.md
  2. +6 −0 index.js
  3. +32 −0 lib/ansi-codes.js
  4. +23 −1 lib/logs-it.js
  5. +8 −0 src/index.coffee
  6. +30 −0 src/lib/ansi-codes.coffee
  7. +14 −1 src/lib/logs-it.coffee
View
@@ -0,0 +1,3 @@
+Logs-it
+
+Super simple logging :)
View
@@ -1,2 +1,8 @@
+/*
+Logs-it by Fadrizul H.
+*/
+var LogsIt;
+LogsIt = require("./lib/logs-it");
+module.exports = new LogsIt;
View
@@ -0,0 +1,32 @@
+/*
+Logs-It by Fadrizul H. - ANSI codes
+*/
+var ansiCodes;
+
+ansiCodes = {
+ off: 0,
+ bold: 1,
+ italic: 3,
+ underline: 4,
+ blink: 5,
+ inverse: 7,
+ hidden: 8,
+ black: 30,
+ red: 31,
+ green: 32,
+ yellow: 33,
+ blue: 34,
+ magenta: 35,
+ cyan: 36,
+ white: 37,
+ black_bg: 40,
+ red_bg: 41,
+ green_bg: 42,
+ yellow_bg: 43,
+ blue_bg: 44,
+ magenta_bg: 45,
+ cyan_bg: 46,
+ white_bg: 47
+};
+
+module.exports = ansiCodes;
View
@@ -1,6 +1,28 @@
/*
Logs-It by Fadrizul H.
*/
-var util;
+var LogsIt, ansiCodes, util;
util = require("util");
+
+ansiCodes = require("./ansi-codes");
+
+LogsIt = (function() {
+
+ function LogsIt() {}
+
+ LogsIt.prototype.inspect = function(input) {
+ var nodeId;
+ nodeId = process.pid;
+ return console.log(this.colourIt("NodeId: " + nodeId + " - " + input, ansiCodes.cyan));
+ };
+
+ LogsIt.prototype.colourIt = function(str, code) {
+ return "\033[" + code + "m " + str;
+ };
+
+ return LogsIt;
+
+})();
+
+module.exports = LogsIt;
View
@@ -0,0 +1,8 @@
+###
+Logs-it by Fadrizul H.
+###
+
+# Load & exports the module
+# ------------------------------------------------------------------------------
+LogsIt = require "./lib/logs-it"
+module.exports = new LogsIt
View
@@ -0,0 +1,30 @@
+###
+Logs-It by Fadrizul H. - ANSI codes
+###
+
+ansiCodes =
+ off : 0
+ bold : 1
+ italic : 3
+ underline : 4
+ blink : 5
+ inverse : 7
+ hidden : 8
+ black : 30
+ red : 31
+ green : 32
+ yellow : 33
+ blue : 34
+ magenta : 35
+ cyan : 36
+ white : 37
+ black_bg : 40
+ red_bg : 41
+ green_bg : 42
+ yellow_bg : 43
+ blue_bg : 44
+ magenta_bg : 45
+ cyan_bg : 46
+ white_bg : 47
+
+module.exports = ansiCodes
View
@@ -5,4 +5,17 @@ Logs-It by Fadrizul H.
# Load dependencies
# ------------------------------------------------------------------------------
-util = require "util"
+util = require "util"
+ansiCodes = require "./ansi-codes"
+
+class LogsIt
+
+ inspect : (input) ->
+ nodeId = process.pid
+ console.log @colourIt "NodeId: #{ nodeId } - #{ input }", ansiCodes.cyan
+
+ colourIt : (str, code) ->
+ return "\033[#{ code }m #{ str }"
+
+
+module.exports = LogsIt

0 comments on commit f4e4d92

Please sign in to comment.