diff options
author | Siri Hansen <[email protected]> | 2017-08-22 15:26:02 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2017-09-05 11:29:10 +0200 |
commit | 2d553a01258416bc977b5afd06f83f22c3ac9ab4 (patch) | |
tree | 4cec63084c8de714e1b30c668e701b6e5457700a /lib | |
parent | 9692bb3126332160cc4eda1f24163f88f5a57672 (diff) | |
download | otp-2d553a01258416bc977b5afd06f83f22c3ac9ab4.tar.gz otp-2d553a01258416bc977b5afd06f83f22c3ac9ab4.tar.bz2 otp-2d553a01258416bc977b5afd06f83f22c3ac9ab4.zip |
sasl: set encoding of SASL report log
This can now be explicitly set by the 'sasl_error_logger'
configuration parameter, but if not set, the default encoding is now
utf8. When printing to this log, the Unicode translation modifier, t,
might be used in the format string.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sasl/doc/src/sasl_app.xml | 9 | ||||
-rw-r--r-- | lib/sasl/src/sasl_report_file_h.erl | 16 |
2 files changed, 20 insertions, 5 deletions
diff --git a/lib/sasl/doc/src/sasl_app.xml b/lib/sasl/doc/src/sasl_app.xml index 0576397f9b..e0693fcb60 100644 --- a/lib/sasl/doc/src/sasl_app.xml +++ b/lib/sasl/doc/src/sasl_app.xml @@ -103,13 +103,16 @@ <tag><c>{file,FileName}</c></tag> <item><p>Installs <c>sasl_report_file_h</c> in the error logger. All reports go to file <c>FileName</c>, which is a - string.</p></item> + string. The file is opened in <c>write</c> mode with encoding + <c>utf8</c>.</p></item> <tag><c>{file,FileName,Modes}</c></tag> <item><p>Same as <c>{file,FileName}</c>, except that <c>Modes</c> allows you to specify the modes used for opening the <c>FileName</c> given to the <seealso marker="kernel:file#open/2">file:open/2</seealso> - call. When not specified, <c>Modes</c> defaults to <c>[write]</c>. - Use <c>[append]</c> to have the <c>FileName</c> open in append mode. + call. By default, the file is opened in <c>write</c> mode + with encoding <c>utf8</c>. Use <c>[append]</c> to have + the <c>FileName</c> open in append mode. A different + encoding can also be specified. <c>FileName</c> is a string.</p></item> <tag><c>false</c></tag> <item><p>No SASL error logger handler is installed.</p></item> diff --git a/lib/sasl/src/sasl_report_file_h.erl b/lib/sasl/src/sasl_report_file_h.erl index 21746839fa..d3b5c7dc0d 100644 --- a/lib/sasl/src/sasl_report_file_h.erl +++ b/lib/sasl/src/sasl_report_file_h.erl @@ -29,15 +29,27 @@ handle_event/2, handle_call/2, handle_info/2, terminate/2]). -init({File, Modes, Type}) when is_list(Modes) -> +init({File, Modes0, Type}) when is_list(Modes0) -> process_flag(trap_exit, true), + Modes1 = + case lists:keymember(encoding,1,Modes0) of + true -> Modes0; + false -> [{encoding,utf8}|Modes0] + end, + Modes = + case [M || M <- Modes1, lists:member(M,[write,append,exclusive])] of + [] -> + [write|Modes1]; + _ -> + Modes1 + end, case file:open(File, Modes) of {ok,Fd} -> {ok, {Fd, File, Type}}; What -> What end. - + handle_event({_Type, GL, _Msg}, State) when node(GL) /= node() -> {ok, State}; handle_event(Event, {Fd, File, Type}) -> |