0.0.14 updated deps, improved datetime stamp

master
David Kebler 2019-04-26 10:07:07 -07:00
parent 1059e18f72
commit 2713cb66ea
3 changed files with 11 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@uci-utils/logger", "name": "@uci-utils/logger",
"version": "0.0.13", "version": "0.0.14",
"description": "Parent Logger for all UCI modules", "description": "Parent Logger for all UCI modules",
"main": "src/logger", "main": "src/logger",
"scripts": { "scripts": {
@ -31,10 +31,10 @@
}, },
"homepage": "https://github.com/uCOMmandIt/uci-changeme#readme", "homepage": "https://github.com/uCOMmandIt/uci-changeme#readme",
"dependencies": { "dependencies": {
"env-paths": "^2.0.0", "env-paths": "^2.2.0",
"make-dir": "^2.0.0", "make-dir": "^3.0.0",
"pino": "^5.11.1", "pino": "^5.12.3",
"pino-pretty": "^2.5.0" "pino-pretty": "^2.6.1"
}, },
"devDependencies": { "devDependencies": {
"chai": "^4.2.0", "chai": "^4.2.0",

View File

@ -9,7 +9,7 @@ see [example](./example/example.js) for explanation of options and use in a es6
```javascript ```javascript
// pretty: {translateTime:true, colorize:true, levelFirst:true } // options for pino pretty printer // pretty: {translateTime:true, colorize:true, levelFirst:true } // options for pino pretty printer
// env:'', // 'dev' or 'pro' -- can be use to set/override UCI_ENV environment variable // env:'', // 'dev' or 'pro' -- can be use to set/override UCI_ENV environment variable
// enForce: false, // only used with .evn. if true will override UCI_ENV if it is set, otherwise no // enForce: false, // only used with .env. if true will override UCI_ENV if it is set, otherwise no
// level:'info', // info is default level, set level to lowest visible // level:'info', // info is default level, set level to lowest visible
// clear: false, // true for log files will clear the current log file on restart // clear: false, // true for log files will clear the current log file on restart
// logFileName:'test', // if not supplied log filename will be generated from timestamp // logFileName:'test', // if not supplied log filename will be generated from timestamp
@ -29,7 +29,7 @@ see [example](./example/example.js) for explanation of options and use in a es6
additional: {anotherprop:'test'} // should do not use any keys above or 'level,logPath,package,instanceCreatedHR,instanceCreated' as keys will be merged additional: {anotherprop:'test'} // should do not use any keys above or 'level,logPath,package,instanceCreatedHR,instanceCreated' as keys will be merged
``` ```
to run the example clone reop and then `npm install` from root to run the example clone repo and then `npm install` from root
then then

View File

@ -18,11 +18,11 @@ function child (opts) {
pretty.search = process.env.UCI_LOG_SEARCH pretty.search = process.env.UCI_LOG_SEARCH
} }
} }
DATE_TIME = new Date(Date.now()).toISOString().replace( /[:.]+/g, '-' ) DATE_TIME = new Date().toString()
LOG_PATH = ( process.env.UCI_ENV.indexOf('pro') > -1 || process.env.UCI_ENV === 'logfile' ) LOG_PATH = ( process.env.UCI_ENV.indexOf('pro') > -1 || process.env.UCI_ENV === 'logfile' )
? ( process.env.UCI_LOG_PATH || `${envPaths(opts.appName || opts.name || 'default').log}/${opts.logFileName || DATE_TIME}.log`) : undefined ? ( process.env.UCI_LOG_PATH || `${envPaths(opts.appName || opts.name || 'default').log}/${opts.logFileName || DATE_TIME}.log`) : undefined
if (LOG_PATH) { if (LOG_PATH) {
try { mkdir(dirname(LOG_PATH)) } try { mkdir(dirname(LOG_PATH)) } // makes recursively for any missing parent directories
catch(err) { throw err } catch(err) { throw err }
} }
} }
@ -51,7 +51,7 @@ function child (opts) {
class: opts.class || ( (typeof opts.package==='string') ? capitalize(basename(opts.package)) : undefined), class: opts.class || ( (typeof opts.package==='string') ? capitalize(basename(opts.package)) : undefined),
id: opts.id || opts.name || 'none', id: opts.id || opts.name || 'none',
instanceCreatedHR:DATE_TIME, instanceCreatedHR:DATE_TIME,
instanceCreated:new Date().getTime() instanceCreated:Date.now()
} }
logOpts = Object.assign(logOpts,opts.additional) logOpts = Object.assign(logOpts,opts.additional)