-
Notifications
You must be signed in to change notification settings - Fork 1
messageKey
Grant Carthew edited this page Oct 25, 2024
·
6 revisions
The messageKey
option enables you to change the JSON key used for the message output.
The messageKey
option is used to change the key used in the output JSON for the message value. For example, the default messageKey
of 'msg' will produce an output from the logger of:
{"level": "info", "lvl": 30, "time": 12345, "msg": "something",...
If you set the messageKey
option to 'message' then the output from the logger would look like:
{"level": "info", "lvl": 30, "time": 12345, "message": "something",...
This example changes the messageKey
from the default of 'msg' to 'message':
import Perj from 'perj'
const log = new Perj({ messageKey: 'message' })
log.info('You have advanced to the next level!')
/*
Standard out will be:
{"level":"info","lvl":30,"time":1525643291716,"message":"You have advanced to the next level!","data":""}
*/