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 2014/02/03 23:12:29 UTC
[15/29] twig commit: updated refs/heads/import to 2d56280
Send messages to stdout if syslog host is undefined
Project: http://git-wip-us.apache.org/repos/asf/couchdb-twig/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-twig/commit/263e0174
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-twig/tree/263e0174
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-twig/diff/263e0174
Branch: refs/heads/import
Commit: 263e0174714747d797037b056ae1cfe1bc9cd377
Parents: 2ca00c3
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Tue Mar 8 17:11:13 2011 -0500
Committer: Adam Kocoloski <ad...@cloudant.com>
Committed: Tue Mar 8 17:11:13 2011 -0500
----------------------------------------------------------------------
src/twig_event_handler.erl | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-twig/blob/263e0174/src/twig_event_handler.erl
----------------------------------------------------------------------
diff --git a/src/twig_event_handler.erl b/src/twig_event_handler.erl
index 1ade02f..2dbab71 100644
--- a/src/twig_event_handler.erl
+++ b/src/twig_event_handler.erl
@@ -96,8 +96,6 @@ get_env(Key, Default) ->
Default
end.
-write(_, _, _, _, #state{host=undefined}) ->
- ok;
write(Level, undefined, Msg, Pid, State) ->
write(Level, "--------", Msg, Pid, State);
write(Level, MsgId, Msg, Pid, State) when is_list(Msg); is_binary(Msg) ->
@@ -107,7 +105,7 @@ write(Level, MsgId, Msg, Pid, State) when is_list(Msg); is_binary(Msg) ->
?SYSLOG_VERSION, twig_util:iso8601_timestamp(), Hostname, App, Pid,
MsgId]),
%% TODO truncate large messages
- gen_udp:send(Socket, Host, Port, [Pre, Msg, $\n]);
+ send(Socket, Host, Port, [Pre, Msg, $\n]);
write(Level, MsgId, {Format0, Args0}, Pid, State) ->
#state{facility=Facil, appid=App, hostname=Hostname, host=Host, port=Port,
socket=Socket} = State,
@@ -116,6 +114,11 @@ write(Level, MsgId, {Format0, Args0}, Pid, State) ->
Hostname, App, Pid, MsgId | Args0],
%% TODO truncate large messages
Packet = io_lib:format(Format, Args),
+ send(Socket, Host, Port, Packet).
+
+send(_, undefined, _, Packet) ->
+ io:put_chars(Packet);
+send(Socket, Host, Port, Packet) ->
gen_udp:send(Socket, Host, Port, Packet).
message(crash_report, Report) ->