25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

* src/ejabberd_logger_h.erl: Speed optimizations

SVN Revision: 481
This commit is contained in:
Alexey Shchepin 2005-12-24 02:40:35 +00:00
parent 784edef4b6
commit 7ee3e45df1
2 changed files with 15 additions and 11 deletions

View File

@ -1,3 +1,7 @@
2005-12-24 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_logger_h.erl: Speed optimizations
2005-12-22 Alexey Shchepin <alexey@sevcom.net>
* src/Makefile.in: Clean results of ASN.1 compiler (thanks to

View File

@ -29,7 +29,7 @@
%% Other
%%----------------------------------------------------------------------
init(File) ->
case file:open(File, [append]) of
case file:open(File, [append, raw]) of
{ok, Fd} ->
{ok, #state{fd = Fd, file = File}};
Error ->
@ -66,7 +66,7 @@ handle_info({'EXIT', _Fd, _Reason}, _State) ->
remove_handler;
handle_info({emulator, _GL, reopen}, State) ->
file:close(State#state.fd),
case file:open(State#state.file, [append]) of
case file:open(State#state.file, [append, raw]) of
{ok, Fd} ->
{ok, State#state{fd = Fd}};
Error ->
@ -101,38 +101,38 @@ write_event(Fd, {Time, {error, _GL, {Pid, Format, Args}}}) ->
T = write_time(Time),
case catch io_lib:format(add_node(Format,Pid), Args) of
S when list(S) ->
io:format(Fd, T ++ S, []);
file:write(Fd, io_lib:format(T ++ S, []));
_ ->
F = add_node("ERROR: ~p - ~p~n", Pid),
io:format(Fd, T ++ F, [Format,Args])
file:write(Fd, io_lib:format(T ++ F, [Format,Args]))
end;
write_event(Fd, {Time, {emulator, _GL, Chars}}) ->
T = write_time(Time),
case catch io_lib:format(Chars, []) of
S when list(S) ->
io:format(Fd, T ++ S, []);
file:write(Fd, io_lib:format(T ++ S, []));
_ ->
io:format(Fd, T ++ "ERROR: ~p ~n", [Chars])
file:write(Fd, io_lib:format(T ++ "ERROR: ~p ~n", [Chars]))
end;
write_event(Fd, {Time, {info, _GL, {Pid, Info, _}}}) ->
T = write_time(Time),
io:format(Fd, T ++ add_node("~p~n",Pid),[Info]);
file:write(Fd, io_lib:format(T ++ add_node("~p~n",Pid), [Info]));
write_event(Fd, {Time, {error_report, _GL, {Pid, std_error, Rep}}}) ->
T = write_time(Time),
S = format_report(Rep),
io:format(Fd, T ++ S ++ add_node("", Pid), []);
file:write(Fd, io_lib:format(T ++ S ++ add_node("", Pid), []));
write_event(Fd, {Time, {info_report, _GL, {Pid, std_info, Rep}}}) ->
T = write_time(Time, "INFO REPORT"),
S = format_report(Rep),
io:format(Fd, T ++ S ++ add_node("", Pid), []);
file:write(Fd, io_lib:format(T ++ S ++ add_node("", Pid), []));
write_event(Fd, {Time, {info_msg, _GL, {Pid, Format, Args}}}) ->
T = write_time(Time, "INFO REPORT"),
case catch io_lib:format(add_node(Format,Pid), Args) of
S when list(S) ->
io:format(Fd, T ++ S, []);
file:write(Fd, io_lib:format(T ++ S, []));
_ ->
F = add_node("ERROR: ~p - ~p~n", Pid),
io:format(Fd, T ++ F, [Format,Args])
file:write(Fd, io_lib:format(T ++ F, [Format,Args]))
end;
write_event(_, _) ->
ok.