fix bugs associated with using package property.
Move to utils subdirectory
master
David Kebler 2019-02-14 14:00:26 -08:00
parent 8c090a8df2
commit 1059e18f72
3 changed files with 8 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@uci-utils/logger",
"version": "0.0.12",
"version": "0.0.13",
"description": "Parent Logger for all UCI modules",
"main": "src/logger",
"scripts": {

View File

@ -50,6 +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_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

@ -44,11 +44,11 @@ function child (opts) {
let logOpts = {
level:opts.level || process.env.UCI_LOG_LEVEL,
logPath: LOG_PATH, // if logging to file
appName: opts.appName,
repo: opts.repo || (opts.package) ? opts.package.replace( /[@]+/g, '' ).replace( /[/]+/g, '-' ) : undefined,
appName: opts.appName || opts.name,
package: opts.package,
file: opts.file || (opts.package) ? `src/${basename(opts.package)}.js` : undefined,
class: opts.class || (opts.package) ? (basename(opts.package).charAt(0).toUpperCase() + opts.package.slice(1)) : undefined,
repo: opts.repo || ((typeof opts.package==='string') ? opts.package.replace( /[@]+/g, '' ).replace( /[/]+/g, '-' ) : undefined),
file: opts.file || ((typeof opts.package==='string') ? `src/${basename(opts.package)}.js` : undefined),
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()
@ -73,3 +73,5 @@ function child (opts) {
}
export default child
function capitalize (s) { return s.charAt(0).toUpperCase() + s.slice(1)}