Comparing version 0.0.38 to 0.0.41
var fs = require('fs') | ||
, request = require('request') | ||
, Step = require('./git/step') | ||
, log = require('./logger').getInstance(); | ||
//, log = require('./logger').getInstance(); | ||
var log = { | ||
error: console.log | ||
} | ||
function readJsonCfg(cfg_path, fn) { | ||
@@ -7,0 +11,0 @@ try { |
@@ -8,2 +8,3 @@ var exports = module.exports | ||
exports.logger = require('./logger'); | ||
exports.simplelog = require('./simplelog'); | ||
exports.cfgutil = require('./cfgutil'); | ||
@@ -10,0 +11,0 @@ exports.sqlutil = require('./sqlutil'); |
@@ -9,2 +9,4 @@ /** | ||
var fs = require('fs') | ||
, util = require('util') | ||
, callerId = require('caller-id') | ||
, _ = require('underscore') | ||
@@ -22,7 +24,7 @@ , defaultPath = fs.existsSync('/tmp') ? '/tmp/node.log' : (__dirname + '/../../../node.log') | ||
var defaultPattern = { | ||
"type": "file", | ||
"type": "dateFile", | ||
"filename": logFile, | ||
"maxLogSize": logMaxSize, | ||
"backups": logBackup, | ||
"category": logCategory | ||
"pattern": "-yyyy-MM-dd.log", | ||
"alwaysIncludePattern": true, | ||
"level":"INFO" | ||
}; | ||
@@ -32,10 +34,3 @@ | ||
{ type: 'console' }, | ||
defaultPattern, | ||
{ | ||
"category": logCategory, | ||
"type": "dateFile", | ||
"filename": logFile, | ||
"pattern": logPattern, | ||
"alwaysIncludePattern": true | ||
} | ||
defaultPattern | ||
]; | ||
@@ -54,5 +49,12 @@ | ||
if(categories.indexOf(catg) < 0) { | ||
if(categories.indexOf(catg) < 0 || catg == logCategory) { | ||
if(!opts) opts = defaultPattern; | ||
opts['category'] = catg; | ||
if(catg == logCategory) { //remove default category for new insert | ||
appenders = _.filter(appenders, function(v) { | ||
if(v.category != logCategory) { | ||
return v; | ||
} | ||
}); | ||
} | ||
appenders.push(opts); | ||
@@ -62,2 +64,8 @@ log4js.configure( { "appenders": appenders } ); | ||
if (appenderNames.indexOf(catg) >= 0) { | ||
return log4js.getLogger(catg); | ||
} else { | ||
appenderNames.push(catg); | ||
} | ||
var logger = log4js.getLogger(catg); | ||
@@ -68,2 +76,3 @@ logger.setLevel(opts.level || process.env.LOGLEVEL || logLevel); | ||
catg, opts.filename); | ||
return logger; | ||
@@ -81,9 +90,6 @@ } | ||
return log4js.getLogger(catg); | ||
} else { | ||
appenderNames.push(catg); | ||
} | ||
} | ||
if (!opts) opts = {} | ||
opts.type = opts['type'] || 'file'; | ||
opts.type = opts['type'] || 'dateFile'; | ||
opts.filename = opts['path'] || logFile; | ||
@@ -93,6 +99,6 @@ opts.category = catg || logCategory; | ||
opts.logPattern = opts.pattern || logPattern; | ||
opts.logMaxSize = opts.logMaxSize || logMaxSize; | ||
opts.logBackup = opts.logBackup || logBackup; | ||
opts.alwaysIncludePattern = opts.alwaysIncludePattern || true; | ||
return addAppender(catg, opts); | ||
} | ||
var nodemailer = require("nodemailer") | ||
, log = require('./logger').getInstance() | ||
, os = require('os') | ||
@@ -15,8 +14,3 @@ , fs = require('fs') | ||
if(json) { | ||
log.debug('Setting the cfg using json...' ); | ||
log.debug(json); | ||
cfg = json; | ||
log.debug('Confirm cfg:'); | ||
log.debug(cfg); | ||
smtpOption = json.smtpOptions; | ||
@@ -23,0 +17,0 @@ } |
{ | ||
"name": "nodeutil", | ||
"description": "Node.js Utility", | ||
"version": "0.0.38", | ||
"version": "0.0.41", | ||
"author": { | ||
"name": "Simon Su", | ||
"email": "simonsu@mitac.com.tw" | ||
"email": "simonsu.mail@gmail.com" | ||
}, | ||
@@ -12,3 +12,3 @@ "contributors": [ | ||
"name": "Simon Su", | ||
"email": "simonsu@mitac.com.tw" | ||
"email": "simonsu.mail@gmail.com" | ||
} | ||
@@ -21,3 +21,4 @@ ], | ||
"log4js": "0.6.3", | ||
"underscore": "~1.5.0" | ||
"underscore": "~1.5.0", | ||
"caller-id": "~0.1.0" | ||
}, | ||
@@ -24,0 +25,0 @@ "devDependencies": { |
@@ -60,2 +60,11 @@ NodeUtil | ||
## Simple Log | ||
Simple log is fix format using js file name and function name as prefix. It is focus that user can easily find the log exist in | ||
``` | ||
var log = require('nodeutil').simplelog; | ||
log.info('Hello %s!'); | ||
``` | ||
## Using dateutil | ||
@@ -62,0 +71,0 @@ |
46242
21
1158
205
6
+ Addedcaller-id@~0.1.0
+ Addedcaller-id@0.1.0(transitive)
+ Addedstack-trace@0.0.10(transitive)