updated pino, also now using pino-pretty. note pino-pretty searches must! be escaped

master
David Kebler 2018-12-04 09:52:45 -08:00
parent 35e46a5953
commit 7d2be397cd
5 changed files with 31 additions and 90 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@uci/logger",
"version": "0.0.4",
"version": "0.0.6",
"description": "Parent Logger for all UCI modules",
"main": "src/logger",
"scripts": {
@ -8,7 +8,8 @@
"test": "mocha -r esmtest/*.test.mjs",
"testci": "istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- -R spec --recursive && codecov || true",
"example": "node -r esm example/example",
"dev": "./node_modules/.bin/nodemon -r esm-e mjs example/example"
"dev": "UCI_DEV=true ./node_modules/.bin/nodemon -r esm example/example",
"log": "UCI_LOG=true ./node_modules/.bin/nodemon -r esm example/example"
},
"author": "David Kebler",
"license": "MIT",
@ -26,15 +27,16 @@
},
"homepage": "https://github.com/uCOMmandIt/uci-changeme#readme",
"dependencies": {
"pino": "^4.10.3"
"pino": "^5.9.0",
"pino-pretty": "^2.4.0"
},
"devDependencies": {
"nodemon": "^1.14.3",
"chai": "^4.1.2",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"codecov": "^3.0.0",
"codecov": "^3.1.0",
"esm": "^3.0.84",
"istanbul": "^0.4.5",
"mocha": "^4.0.1"
"mocha": "^5.2.0",
"nodemon": "^1.18.7"
}
}

View File

@ -1,10 +1,17 @@
# uCOMmandIt Template Package Repository
<!-- find and replace the package name to match -->
[![Build Status](https://img.shields.io/travis/uCOMmandIt/uci-pkg-template.svg?branch=master)](https://travis-ci.org/uCOMmandIt/uci-pkg-template)
[![Inline docs](http://inch-ci.org/github/uCOMmandIt/uci-pkg-template.svg?branch=master)](http://inch-ci.org/github/uCOMmandIt/uci-pkg-template)
[![Dependencies](https://img.shields.io/david/uCOMmandIt/uci-pkg-template.svg)](https://david-dm.org/uCOMmandIt/uci-pkg-template)
[![devDependencies](https://img.shields.io/david/dev/uCOMmandIt/uci-pkg-template.svg)](https://david-dm.org/uCOMmandIt/uci-pkg-template?type=dev)
[![codecov](https://img.shields.io/codecov/c/github/uCOMmandIt/uci-pkg-template/master.svg)](https://codecov.io/gh/uCOMmandIt/uci-pkg-template)
# uCOMmandIt JSON Logger
runtime module logger based on pino
run example as either
`npm run log`
for json logging
or for pretty output `npm run dev`
for search/filter use environment variable
`UCI_LOG_SEARCH='key == `\`value\``' npm run dev`
note: ALL search values regardless of type MUST be escaped with ``

View File

@ -1,10 +1,9 @@
import pino from 'pino'
let pretty = null
let pretty = false
if(process.env.UCI_DEV) {
pretty = pino.pretty()
pretty.pipe(process.stdout)
pretty = process.env.UCI_LOG_PRETTY || {translateTime:true, colorize:true, levelFirst:true }
pretty.search = process.env.UCI_LOG_SEARCH
}
let LOG = process.env.UCI_LOG || process.env.UCI_DEV
@ -16,8 +15,9 @@ const logger = pino({
serializers: {
req: pino.stdSerializers.req,
res: pino.stdSerializers.res
}
},pretty)
},
prettyPrint: pretty
})
function child (opts) {
const LOG_OPTS = {

View File

@ -1,49 +0,0 @@
import aClass from '../src'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
chai.use(chaiAsPromised)
const expect = chai.expect
describe(
'Testing ',
function () {
hooks()
sometests()
someothertests()
})
//****************** TESTS **********************
function sometests() {
it('==> test something', async function () {
let result = await someasyncfunction()
expect(result, 'test failed').to.equal('expectedresult')
})
}
function someothertests() {
it('==> test something', async function () {
let result = await someasyncfunction()
expect(result, 'test failed').to.equal('expectedresult')
})
}
function hooks() {
before(async() => {
await someasyncfunctiontodobefore()
})
beforeEach(async() => {
await someasyncfunctiontodobeforeeachtest()
})
after(async() => {
await someasyncfunctiontodoaftereeachtest()
})
}

View File

@ -1,19 +0,0 @@
import changeme from '../src/changeme'
import path from 'path'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
const { assert } = chai;
chai.use(chaiAsPromised);
const expect = chai.expect
describe('Promise Stuff - ', function () {
it('Can test a promise', function () {
return expect(changeme.apromise).to.eventually.equal('some promise hey')
return Promise.resolve().then(() => expect(changeme.apromise).to.eventually.equal('some promise hey'))
})
})