Comparing version 1.0.3 to 1.0.4
@@ -29,2 +29,4 @@ // Copyright Teleportd | ||
* Factory | ||
* | ||
* @param { logging, debug, name } | ||
*/ | ||
@@ -35,4 +37,9 @@ var factory = function(spec, my) { | ||
my.LOGGING = spec.logging || true; | ||
my.DEBUG = spec.debug || false; | ||
my.name = spec.name; | ||
// public | ||
var forward; /* forward(obj, type, evt); */ | ||
var log; /* log(str); */ | ||
@@ -49,4 +56,31 @@ // private | ||
log = function(str, debug) { | ||
if(!my.LOGGING) return; | ||
var pre = '[' + new Date().toISOString() + '] '; | ||
pre += (my.name ? '{' + my.name.toUpperCase() + '} ' : ''); | ||
pre += (debug ? 'DEBUG: ' : ''); | ||
str.split('\n').forEach(function(line) { | ||
console.log(pre + line); | ||
}); | ||
}; | ||
my.log = { | ||
out: function(str) { | ||
log(str); | ||
}, | ||
error: function(err) { | ||
log('*********************************************'); | ||
log('ERROR: ' + err.message); | ||
log('*********************************************'); | ||
log(err.stack); | ||
log('---------------------------------------------'); | ||
}, | ||
debug: function(str) { | ||
if(my.DEBUG) | ||
log(str, true); | ||
} | ||
}; | ||
base.method(that, 'forward', forward, _super); | ||
base.getter(that, 'log', my, 'log'); | ||
@@ -64,3 +98,4 @@ return that; | ||
* exports = factory({}); | ||
* exports = factory({ name: 'vacuum' }); | ||
* ``` | ||
*/ |
{ | ||
"name": "fwk", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Simple JS framework for node.js", | ||
@@ -5,0 +5,0 @@ "keywords": ["fwk", "node"], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48854
1458