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",
"version": "0.0.13",
"version": "0.0.14",
"description": "Parent Logger for all UCI modules",
"main": "src/logger",
"scripts": {
@ -31,10 +31,10 @@
},
"homepage": "https://github.com/uCOMmandIt/uci-changeme#readme",
"dependencies": {
"env-paths": "^2.0.0",
"make-dir": "^2.0.0",
"pino": "^5.11.1",
"pino-pretty": "^2.5.0"
"env-paths": "^2.2.0",
"make-dir": "^3.0.0",
"pino": "^5.12.3",
"pino-pretty": "^2.6.1"
},
"devDependencies": {
"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
// 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
// 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
// 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
@ -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
```
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
@ -50,7 +50,7 @@ available scripts for example file
- `UCI_ENV='dev'|'pro'|'node'`, `dev` outputs to console, `pro` outputs to file, `node` will follow whatever `NODE_ENV` is set to.
- `UCI_LOG_PATH=<some file path>` force logging to go to some particular file, also setable via options, see above
- `UCI_LOG_JSON=true` will not pretty output to console but rather as raw json. Useful for piping to a json log processor such as pino-colada
- `UCI_LOG_LEVEL='trace'|'debug'|'info'|'warn'|'error'|fatal'` `warn` is default, can set at runtime with `.lvlset(level)`
- `UCI_LOG_LEVEL='trace'|'debug'|'info'|'warn'|'error'|fatal'` `warn` is default, can set at runtime with `.lvlset(level)`
- `UCI_LOG_PRETTY`={} the pretty option for pino pretty, also setable via options, see above
- `UCI_LOG_SEARCH='key == `\``value`\``'` will filter pretty/dev logs. _note:_ ALL search values regardless of type MUST be escaped with ``

View File

@ -18,11 +18,11 @@ function child (opts) {
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' )
? ( process.env.UCI_LOG_PATH || `${envPaths(opts.appName || opts.name || 'default').log}/${opts.logFileName || DATE_TIME}.log`) : undefined
if (LOG_PATH) {
try { mkdir(dirname(LOG_PATH)) }
try { mkdir(dirname(LOG_PATH)) } // makes recursively for any missing parent directories
catch(err) { throw err }
}
}
@ -51,7 +51,7 @@ function child (opts) {
class: opts.class || ( (typeof opts.package==='string') ? capitalize(basename(opts.package)) : undefined),
id: opts.id || opts.name || 'none',
instanceCreatedHR:DATE_TIME,
instanceCreated:new Date().getTime()
instanceCreated:Date.now()
}
logOpts = Object.assign(logOpts,opts.additional)