# Compromise solution
## All developers would agree on
1. all new log statements should receive proplist type for args.
2. we should discourage use of string formatter directives (such as `~p`)
3. The Message in the call shouldn't have any data embedded
## Implementation
1. We would implement `couch_log:Level(Message, Args, Meta)` interface using
parse_transform and merl.
2. The implementation would support both plane list and proplist for Args (for
compatibility reasons)
3. The `io_lib:format` call would be done in the formatters (which need it).
4. In case when keys supplied via Args collide with automatically injected in
Meta, Args takes precedence.
## Examples
### Old style logging call
`couch_log:error("Compaction started for ~p~n", ["shards/...."])`
line formatter output
`Compaction started for shards/..... [pid=<0.11.0>, line=123,
file=couch_db_updater.erl, arg_1="shards/..."]`
json formatter output
```
{
"message": "Compaction started for ~p~n",
"line": 123,
"file": "couch_db_updater.erl",
"pid": "<0.11.0>",
"arg_1": "shards/..."
}
```
### New style logging
`couch_log:error("Compaction started", [{shard, "shards/..."}], [{user,
"foo"}]).`
line formatter output
`Compaction started. [pid=<0.11.0>, line=123, file=couch_db_updater.erl,
shard="shards/...", user="foo"]`
json formatter output
```
{
"message": "Compaction started for ~p~n",
"line": 123,
"file": "couch_db_updater.erl",
"pid": "<0.11.0>",
"shard": "shards/...",
"user": "foo"
}
```
[ Full content available at: https://github.com/apache/couchdb/issues/1373 ]
This message was relayed via gitbox.apache.org for [email protected]