Closed jamesaimonetti closed 13 years ago
This is actually correct behavior. Compare the output of this test program:
https://gist.github.com/851995
What's happening here is that embedded newlines are printed as literals. From the syslog(3) man page on OSX:
Newlines and other non-printable characters embedded in the message string are
printed in an alternate format. This prevents someone from using non-printable char-
acters to construct misleading log messages in an output file. Newlines are printed
as "\n", tabs are printed as "\t". Other control characters are printed using a
caret ("^") representation, for example "^M" for carriage return.
This effectively means that syslog messages must be on a single line. If you want to print an erlang term to a syslog message, you might want to consider using ~w instead of ~p, ~w doesn't try to wrap the line.
Alternately, you could write a wrapper that splits the output on \n and syslogs each line independently.
Str = io_lib:format("~p", [lists:seq(1,100)]), syslog:log(info, Str).
Expected: Pretty print of term matches what is printed in the shell. 1> io:format("~p~n", [lists:seq(1,100)]). [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28, 29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53, 54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78, 79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100] ok 2>
Actual: Where newlines are printed in the shell, #012 is printed instead, and all on one line. Mar 2 14:55:50 thinky64 apps@thinky64[28937]: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,#012 16,17,18,19,20,21,22,23,24,25,26,27,#012 28,29,30,31,32,33,34,35,36,37,38,39,#012 40,41,42,43,44,45,46,47,48,49,50,51,#012 52,53,54,55,56,57,58,59,60,61,62,63,#012 64,65,66,67,68,69,70,71,72,73,74,75,#012 76,77,78,79,80,81,82,83,84,85,86,87,#012 88,89,90,91,92,93,94,95,96,97,98,99,#012 100]