Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…g strings
  • Loading branch information...
commit f4e4d923b1a075a83b1f8445510de2225df5f1d9 1 parent 40f7130
@fadrizul authored
View
3  README.md
@@ -0,0 +1,3 @@
+Logs-it
+
+Super simple logging :)
View
6 index.js
@@ -1,2 +1,8 @@
+/*
+Logs-it by Fadrizul H.
+*/
+var LogsIt;
+LogsIt = require("./lib/logs-it");
+module.exports = new LogsIt;
View
32 lib/ansi-codes.js
@@ -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
24 lib/logs-it.js
@@ -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
8 src/index.coffee
@@ -0,0 +1,8 @@
+###
+Logs-it by Fadrizul H.
+###
+
+# Load & exports the module
+# ------------------------------------------------------------------------------
+LogsIt = require "./lib/logs-it"
+module.exports = new LogsIt
View
30 src/lib/ansi-codes.coffee
@@ -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
15 src/lib/logs-it.coffee
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.