How to custom log format

currently

let str = JSON.stringify(msg.payload);
node.warn(str); 
return msg;

the output is
2 Jul 06:56:16 - [warn] [function:1a91795a.0f8ff7] { "msg": {...}}

How to implement a custom format

for example:

node.warn(["my-tag"],str);

2 Jul 06:56:16 - [warn] [my-tag] [function:1a91795a.0f8ff7] { "msg": {...}}

See custom logging in the docs Logging : Node-RED

Use node-red-contrib-flogger, set < incl topic in it's node config, then set the message topic to "my-tag".