couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1135349 - /couchdb/branches/1.0.x/src/couchdb/couch_log.erl
Date Tue, 14 Jun 2011 00:29:08 GMT
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"),



Mime
View raw message