Permalink
Browse files

initial commit

  • Loading branch information...
thegoleffect committed Dec 26, 2012
1 parent 7683b89 commit 255cf285dd4a476189edd0c4a6b5d5af99d7394e
Showing with 68 additions and 1 deletion.
  1. +3 −0 .gitignore
  2. +16 −1 README.md
  3. +1 −0 index.js
  4. +3 −0 lib/index.js
  5. +30 −0 lib/log.js
  6. +15 −0 package.json
View
@@ -12,3 +12,6 @@ logs
results
npm-debug.log
+
+node_modules/
+*.DS_Store
View
@@ -1,4 +1,19 @@
multitool
=========
-swiss army knife of useful javascript functions
+swiss army knife of useful javascript functions
+
+
+## Log
+
+ LOGLEVEL=trace node index.js
+
+### index.js
+ var multitool = require("multitool");
+ var l = new multitool.Log();
+ var debug = l.debug;
+ var trace = l.trace;
+
+ debug("debug loglevel enabled")
+ trace("debug loglevel enabled")
+
View
@@ -0,0 +1 @@
+var multitool = require("./lib");
View
@@ -0,0 +1,3 @@
+module.exports = {
+ Log: require("./log")
+}
View
@@ -0,0 +1,30 @@
+var Log = function () {
+ var self = this;
+ this.level = process.env.LOGLEVEL.toLowerCase();
+
+ var keys = Object.keys(Log.logLevels);
+ for(var index in keys) {
+ var key = keys[index];
+ if (Log.logLevels.hasOwnProperty(key)) {
+ this[key] = (function(self, key) {
+ return function () {
+ if (Log.logLevels[key] <= Log.logLevels[self.level]) {
+ var args = Array.prototype.slice.call(arguments);
+ args.unshift("[" + key + "]");
+ console.log.apply(console.log, args)
+ }
+ }
+ })(self, key);
+ }
+ }
+};
+
+Log.logLevels = {
+ 'error': 0,
+ 'warn': 1,
+ 'info': 2,
+ 'debug': 3,
+ 'trace': 4
+};
+
+module.exports = Log;
View
@@ -0,0 +1,15 @@
+{
+ "name": "multitool",
+ "version": "0.0.1",
+ "description": "swiss army knife of useful javascript functions",
+ "main": "index.js",
+ "scripts": {
+ "test": "make test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/thegoleffect/multitool.git"
+ },
+ "author": "Van Nguyen <thegoleffect@gmail.com>",
+ "license": "BSD"
+}

0 comments on commit 255cf28

Please sign in to comment.