Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to @hapi/hapi@20.2.1 and pino-pretty@7.2.0 #146

Merged
merged 1 commit into from Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
78 changes: 78 additions & 0 deletions benchmarks/hapi-pino-with-pino-pretty.js
@@ -0,0 +1,78 @@
'use strict'
// see docs https://github.com/pinojs/pino/blob/master/docs/pretty.md *prod
// see docs https://github.com/pinojs/pino-pretty *dev
const Hapi = require('@hapi/hapi')
// manage logs
const Pino = require('..')
// const sonic = require('sonic-boom')
// const Path = require('path')
// const { join } = require('path')

const getResponse = [
{ string: 'string1', number: 1, boolean: true },
{ string: 'string2', number: 2, boolean: false }
]

async function start () {
// Create a server with a host and port
const server = Hapi.server({
host: 'localhost',
port: 3000,
debug: false // disable Hapi debug console logging
})

// Add the route
server.route({
method: 'GET',
path: '/items',
handler: async function (request, h) {
// test sonicBoob library works
// const sonic = new SonicBoom({
// dest: './pino-logs/node_trace.1.log',
// append: true,
// mkdir: true
// });
return h.response(getResponse)
}
})
// const tmpDir = Path.join(__dirname, '.tmp_' + Date.now())
// const destination = join(tmpDir, 'output')

await server.register({
plugin: Pino,
options: {
logPayload: true,
mergeHapiLogData: true,
ignorePaths: ['/alive.txt', '/private'],
ignoreFunc: (options, request) => request.path.startsWith('/private'),
transport: {
target: 'pino-pretty',
options: {
colorize: true,
minimumLevel: 'info',
levelFirst: true,
messageFormat: true,
timestampKey: 'time',
translateTime: true,
singleLine: true,
mkdir: true,
append: true // the next line is breaking the app
// destination: new sonic({
// dest: destination || 1,
// append: true,
// mkdir: true,
// sync: true
// })
}
}
}
})
await server.start()
server.log(['info'], `server running: ${server.info.uri}/items`)
return server
}

start().catch((err) => {
console.log(err)
process.exit(1)
})
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -20,7 +20,7 @@
"license": "MIT",
"devDependencies": {
"@hapi/code": "^8.0.0",
"@hapi/hapi": "^20.0.0",
"@hapi/hapi": "^20.2.1",
"@hapi/lab": "^24.3.2",
"coveralls": "^3.0.11",
"flush-write-stream": "^2.0.0",
Expand All @@ -34,7 +34,7 @@
"abstract-logging": "^2.0.0",
"get-caller-file": "^2.0.5",
"pino": "^7.0.0",
"pino-pretty": "^4.0.0"
"pino-pretty": "^7.2.0"
},
"repository": {
"type": "git",
Expand Down