Having the ability to customize the key for the default msg field during logger initialization would provide greater flexibility in shaping log output to meet diverse formatting requirements. This enhancement would not only make it easier to adapt Logrus to existing logging standards but also enable teams to ensure consistency across different systems and workflows.
Proposed Solution:
Introduce a new field in the TextFormatter (and potentially other formatters) to allow users to set a custom field name for msg. For example, this could be done with a CustomFieldKeyMsg option.
{
"animal": "walrus",
"level": "info",
"msg": "A group of walrus emerges from the ocean",
"size": 10,
"time": "2014-03-10 19:57:38.562264131 -0400 EDT"
}
To this:
{
"animal": "walrus",
"level": "info",
"event": "A group of walrus emerges from the ocean",
"size": 10,
"time": "2014-03-10 19:57:38.562264131 -0400 EDT"
}
Trying to implement this, I realized that this functionality has already been implemented. Apologies for the oversight! Thank you for the great work on Logrus.
Description:
Having the ability to customize the key for the default msg field during logger initialization would provide greater flexibility in shaping log output to meet diverse formatting requirements. This enhancement would not only make it easier to adapt Logrus to existing logging standards but also enable teams to ensure consistency across different systems and workflows.
Proposed Solution:
Introduce a new field in the TextFormatter (and potentially other formatters) to allow users to set a custom field name for
msg
. For example, this could be done with a CustomFieldKeyMsg option.The log output would change from this:
To this: