You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2011/06/14 02:29:08 UTC
svn commit: r1135349 - /couchdb/branches/1.0.x/src/couchdb/couch_log.erl
Author: davisp
Date: Tue Jun 14 00:29:08 2011
New Revision: 1135349
URL: http://svn.apache.org/viewvc?rev=1135349&view=rev
Log:
COUCHDB-1158 - Allow Unicode in in log messages.
This is a hand crafted backport of 1101896 from trunk
because the logger has had many other changes.
Modified:
couchdb/branches/1.0.x/src/couchdb/couch_log.erl
Modified: couchdb/branches/1.0.x/src/couchdb/couch_log.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_log.erl?rev=1135349&r1=1135348&r2=1135349&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/couchdb/couch_log.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_log.erl Tue Jun 14 00:29:08 2011
@@ -131,11 +131,11 @@ terminate(_Arg, {Fd, _LoggingLevel, _Sas
file:close(Fd).
log(Fd, Pid, Level, Format, Args) ->
- Msg = io_lib:format(Format, Args),
- ok = io:format("[~s] [~p] ~s~n", [Level, Pid, Msg]), % dump to console too
- Msg2 = re:replace(lists:flatten(Msg),"\\r\\n|\\r|\\n", "\r\n",
- [global, {return, list}]),
- ok = io:format(Fd, "[~s] [~s] [~p] ~s\r~n\r~n", [httpd_util:rfc1123_date(), Level, Pid, Msg2]).
+ ConsoleMsg = unicode:characters_to_binary(io_lib:format(
+ "[~s] [~p] " ++ Format ++ "~n", [Level, Pid | Args])),
+ FileMsg = ["[", httpd_util:rfc1123_date(), "] ", ConsoleMsg],
+ ok = io:put_chars(ConsoleMsg),
+ ok = io:put_chars(Fd, iolist_to_binary(FileMsg)).
read(Bytes, Offset) ->
LogFileName = couch_config:get("log", "file"),