Repository: pinojs/pino (js)

Issue:
message not taking precedence over mergedObject
I'm creating a simple wrapper around Pino like that

```
const logger = pino({
  base: null,
  messageKey: 'message'
});

export default logger;
```

And I have `jest` test like that

```
it("should log an object", () => {
    const spy = jest.spyOn(process.stdout, "write");
    logger.info({ data: 123, test: true, message: "Message from mergingObject" }, "Message");

    expect(spy).toHaveBeenCalled();

    // Get the first argument of the first call
    const argument = spy.mock.calls[0][0];
    expect(argument).toBeTruthy();

    const data = JSON.parse(argument);
    expect(data.time).toBeGreaterThan(0);
    expect(data.v).toBeGreaterThan(0);
    expect(data.level).toEqual(30);
    expect(data.message).toEqual("Message");
  });
```

This test fails because of `data.message = Message from mergingObject`. But according to the docs

> The message parameter takes precedence over the mergedObject. That is, if a mergedObject contains a msg property, and a message parameter is supplied in addition, the msg property in the output log will be the value of the message parameter not the value of the msg property on the mergedObject.

Am I missing something or is it a bug?

Pull request description:
Fix message precedence over mergedObject
Fixes #615 

Patch:
diff --git a/lib/tools.js b/lib/tools.js
index 92d44bc..41427eb 100644
--- a/lib/tools.js
+++ b/lib/tools.js
@@ -79,12 +79,11 @@ function asJson (obj, msg, num, time) {
   const chindings = this[chindingsSym]
   const serializers = this[serializersSym]
   var data = this[lsCacheSym][num] + time
-  if (msg !== undefined) {
-    data += messageKeyString + asString('' + msg)
-  }
+
   // we need the child bindings added to the output first so instance logged
   // objects can take precedence when JSON.parse-ing the resulting log line
   data = data + chindings
+
   var value
   if (hasObj === true) {
     var notHasOwnProperty = obj.hasOwnProperty === undefined
@@ -131,6 +130,11 @@ function asJson (obj, msg, num, time) {
       }
     }
   }
+
+  if (msg !== undefined) {
+    data += messageKeyString + asString('' + msg)
+  }
+
   return data + end
 }
 


Test patch:
diff --git a/test/basic.test.js b/test/basic.test.js
index f164f21..483b0cf 100644
--- a/test/basic.test.js
+++ b/test/basic.test.js
@@ -76,6 +76,24 @@ function levelTest (name, level) {
     })
   })
 
+  test(`overriding object key by string at level ${name}`, async ({ is, same }) => {
+    const stream = sink()
+    const instance = pino(stream)
+    instance.level = name
+    instance[name]({ hello: 'world', msg: 'object' }, 'string')
+    const result = await once(stream, 'data')
+    is(new Date(result.time) <= new Date(), true, 'time is greater than Date.now()')
+    delete result.time
+    same(result, {
+      pid: pid,
+      hostname: hostname,
+      level: level,
+      msg: 'string',
+      hello: 'world',
+      v: 1
+    })
+  })
+
   test(`formatting logs as ${name}`, async ({ is }) => {
     const stream = sink()
     const instance = pino(stream)