R21 logger mangles map messages

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

R21 logger mangles map messages

Mark Geib-2
I am migrating an application to R21 to try out the new logger. When I log a message with a map, using “~p”, it appears like:

#{pmt_pid =>, 33, program_number =>, 5837} <-----(notice the extra commas after each =>)

compared to io:format output of #{pmt_pid => 33, program_number => 5837}

In both cases my formatting is “~p”.

Has anyone seen this before.??

Thanks,

Mark.

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

signature.asc (540 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: R21 logger mangles map messages

Siri Hansen
It is probably the single_line property on the formatter that causes this. If single_line is true (default), then the formatted string is converted to a single line by replacing all newlines with ", " (comma, space). Could you please try to set single_line to false and let me see the output? The property can be set as follows (if the printout comes from the default handler):

logger:update_formatter_config(default,single_line,false).

Regards
/siri

Den ons. 8. aug. 2018 kl. 23:01 skrev Mark Geib <[hidden email]>:
I am migrating an application to R21 to try out the new logger. When I log a message with a map, using “~p”, it appears like:

#{pmt_pid =>, 33, program_number =>, 5837} <-----(notice the extra commas after each =>)

compared to io:format output of #{pmt_pid => 33, program_number => 5837}

In both cases my formatting is “~p”.

Has anyone seen this before.??

Thanks,

Mark.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: R21 logger mangles map messages

Mark Geib-2
Yes that removed the extra commas. Of course now the log messages are multi-line.

So to get a single line message for maps, without the commas, is the only approach to format the message with something like
io_lib:print(MyBigMap,1,8192,-1) and then log the string?

These log messages are being consumed by splunk, so the commas are causing problems, and the messages need to be single line.

Thanks,
Mark.


On Aug 9, 2018, at 2:31 AM, Siri Hansen <[hidden email]> wrote:

It is probably the single_line property on the formatter that causes this. If single_line is true (default), then the formatted string is converted to a single line by replacing all newlines with ", " (comma, space). Could you please try to set single_line to false and let me see the output? The property can be set as follows (if the printout comes from the default handler):

logger:update_formatter_config(default,single_line,false).

Regards
/siri

Den ons. 8. aug. 2018 kl. 23:01 skrev Mark Geib <[hidden email]>:
I am migrating an application to R21 to try out the new logger. When I log a message with a map, using “~p”, it appears like:

#{pmt_pid =>, 33, program_number =>, 5837} <-----(notice the extra commas after each =>)

compared to io:format output of #{pmt_pid => 33, program_number => 5837}

In both cases my formatting is “~p”.

Has anyone seen this before.??

Thanks,

Mark.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

signature.asc (540 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: R21 logger mangles map messages

Max Lapshin-2
Oh, I see  mpegts =)

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: R21 logger mangles map messages

Siri Hansen
In reply to this post by Mark Geib-2


Den tor. 9. aug. 2018 kl. 16:42 skrev Mark Geib <[hidden email]>:
Yes that removed the extra commas. Of course now the log messages are multi-line.

So to get a single line message for maps, without the commas, is the only approach to format the message with something like
io_lib:print(MyBigMap,1,8192,-1) and then log the string?

Yes, or you could specify field with 0 with ~p to indicate infinite line length, e.g.

logger:notice("my map: ~0p",[MyMap])

(Using the value 0 here is new from OTP-21, see the description of control sequence 'p' in the ref.man for io:format.)

I do, however, see this a bug in logger. It needs to be a bit more sophisticated when ensuring single line - I'm looking into it.

Regards
/siri

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: R21 logger mangles map messages

Mark Geib-2
So the combination of single_line => true, and the ~0p format field gives me what I want.
Thanks.

On Aug 10, 2018, at 3:07 AM, Siri Hansen <[hidden email]> wrote:



Den tor. 9. aug. 2018 kl. 16:42 skrev Mark Geib <[hidden email]>:
Yes that removed the extra commas. Of course now the log messages are multi-line.

So to get a single line message for maps, without the commas, is the only approach to format the message with something like
io_lib:print(MyBigMap,1,8192,-1) and then log the string?

Yes, or you could specify field with 0 with ~p to indicate infinite line length, e.g.

logger:notice("my map: ~0p",[MyMap])

(Using the value 0 here is new from OTP-21, see the description of control sequence 'p' in the ref.man for io:format.)

I do, however, see this a bug in logger. It needs to be a bit more sophisticated when ensuring single line - I'm looking into it.

Regards
/siri


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

signature.asc (540 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: R21 logger mangles map messages

Siri Hansen
Great! I'm currently testing an improved single_line implementation in logger_formatter, which modifies the field width to 0 for all ~p/~P in the format strings before replacing the rest of the newlines by ", " as before. It will be included in OTP-21.1.
/siri

Den fre. 10. aug. 2018 kl. 21:27 skrev Mark Geib <[hidden email]>:
So the combination of single_line => true, and the ~0p format field gives me what I want.
Thanks.

On Aug 10, 2018, at 3:07 AM, Siri Hansen <[hidden email]> wrote:



Den tor. 9. aug. 2018 kl. 16:42 skrev Mark Geib <[hidden email]>:
Yes that removed the extra commas. Of course now the log messages are multi-line.

So to get a single line message for maps, without the commas, is the only approach to format the message with something like
io_lib:print(MyBigMap,1,8192,-1) and then log the string?

Yes, or you could specify field with 0 with ~p to indicate infinite line length, e.g.

logger:notice("my map: ~0p",[MyMap])

(Using the value 0 here is new from OTP-21, see the description of control sequence 'p' in the ref.man for io:format.)

I do, however, see this a bug in logger. It needs to be a bit more sophisticated when ensuring single line - I'm looking into it.

Regards
/siri


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions