Repository: pinojs/hapi-pino
Pull request #158 (2022-03-15 10:14:15)

fix: update dependencies
Code changes were done with `standard --fix`.


Patch:
diff --git a/index.js b/index.js
index 6d011d7..f2b8b5e 100644
--- a/index.js
+++ b/index.js
@@ -37,7 +37,7 @@ async function register (server, options) {
     options.logEvents = ['onPostStart', 'onPostStop', 'response', 'request-error']
   }
 
-  var logger
+  let logger
   if (options.instance) {
     logger = options.instance
     const overrideDefaultErrorSerializer =
@@ -51,7 +51,7 @@ async function register (server, options) {
       options.transport.caller = getCallerFile()
     }
     options.stream = options.stream || process.stdout
-    var stream = options.stream || process.stdout
+    const stream = options.stream || process.stdout
     logger = pino(options, stream)
   }
 
@@ -69,7 +69,7 @@ async function register (server, options) {
     tagToLevelValue[tag] = logger.levels.values[tagToLevels[tag]]
   }
 
-  var ignoreTable = {}
+  const ignoreTable = {}
   if (options.ignorePaths) {
     for (let i = 0; i < options.ignorePaths.length; i++) {
       ignoreTable[options.ignorePaths[i]] = true
@@ -215,7 +215,7 @@ async function register (server, options) {
       return false
     }
 
-    for (var index = ignoreTags.length; index >= 0; index--) {
+    for (let index = ignoreTags.length; index >= 0; index--) {
       if (routeTags.includes(ignoreTags[index])) {
         return true
       }
@@ -229,7 +229,7 @@ async function register (server, options) {
   }
 
   function tryAddEvent (server, options, type, event, cb) {
-    var name = typeof event === 'string' ? event : event.name
+    const name = typeof event === 'string' ? event : event.name
     if (isEnabledLogEvent(options, name)) {
       if (type === 'on') {
         server.events.on(event, cb)
@@ -247,12 +247,12 @@ async function register (server, options) {
       return
     }
 
-    var tags = event.tags
-    var data = event.data
+    const tags = event.tags
+    let data = event.data
 
-    var logObject
+    let logObject
     if (mergeHapiLogData) {
-      if (typeof data === 'string') {
+      if (typeof data === 'string' || typeof data === 'number') {
         data = { [messageKey]: data }
       }
 
diff --git a/package.json b/package.json
index e46b4c8..cf6ae53 100644
--- a/package.json
+++ b/package.json
@@ -20,24 +20,24 @@
   ],
   "license": "MIT",
   "devDependencies": {
-    "@hapi/code": "^8.0.0",
+    "@hapi/code": "^8.0.7",
     "@hapi/hapi": "^20.2.1",
-    "@hapi/lab": "^24.3.2",
-    "coveralls": "^3.0.11",
+    "@hapi/lab": "^24.5.1",
+    "coveralls": "^3.1.1",
     "flush-write-stream": "^2.0.0",
     "make-promises-safe": "^5.1.0",
-    "pino-pretty": "^7.2.0",
+    "pino-pretty": "^7.5.3",
     "pre-commit": "^1.2.2",
-    "split2": "^3.1.1",
-    "standard": "^14.3.3",
-    "tsd": "^0.18.0"
+    "split2": "^4.1.0",
+    "standard": "^16.0.4",
+    "tsd": "^0.19.1"
   },
   "dependencies": {
-    "@hapi/hoek": "^9.0.0",
-    "@types/hapi__hapi": "^20.0.9",
-    "abstract-logging": "^2.0.0",
+    "@hapi/hoek": "^9.2.1",
+    "@types/hapi__hapi": "^20.0.10",
+    "abstract-logging": "^2.0.1",
     "get-caller-file": "^2.0.5",
-    "pino": "^7.0.0"
+    "pino": "^7.8.1"
   },
   "repository": {
     "type": "git",


Test patch:
diff --git a/test.js b/test.js
index aa3d5f0..7644129 100644
--- a/test.js
+++ b/test.js
@@ -49,7 +49,7 @@ function getServer () {
 }
 
 function sink (func) {
-  var result = split(JSON.parse)
+  const result = split(JSON.parse)
   result.pipe(writeStream.obj(func))
   return result
 }
@@ -1336,6 +1336,30 @@ experiment('logging with mergeHapiLogData option enabled', () => {
     await finish
   })
 
+  test('when data is a number, merge it as msg property', async () => {
+    const server = getServer()
+    let done
+    const finish = new Promise(function (resolve, reject) {
+      done = resolve
+    })
+    const stream = sink(data => {
+      expect(data).to.include({ msg: 1 })
+      done()
+    })
+    const plugin = {
+      plugin: Pino,
+      options: {
+        stream: stream,
+        level: 'info',
+        mergeHapiLogData: true
+      }
+    }
+
+    await server.register(plugin)
+    server.log(['info'], 1)
+    await finish
+  })
+
   test('respects `messageKey` option', async () => {
     const server = getServer()
     let done