Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added basic log4erl support

  • Loading branch information...
commit 5096cb55e4f6b803334eea521e38f1ac953eb2e5 1 parent fe7dc1f
ingo authored
View
2  README
@@ -19,6 +19,8 @@ geronimo-jta_1.1_spec-1.1.1.jar
neo4j-kernel-1.1.jar
neo4j-index-1.1.jar
+log4erl-0.9.0
+
NOTE: Dependency management is by hand for now.
Later we may use Ivy or Maven for Java dependencies.
View
14 conf.sh
@@ -6,6 +6,7 @@ SCRIPT_DIR="`( cd \"${SCRIPT_DIR}\" && pwd )`"
JAVA_DIST=$SCRIPT_DIR/java/dist
JAVA_LIB=$SCRIPT_DIR/java/lib
+ERL_LIB=$SCRIPT_DIR/erl/priv
if [ -f conf.cache ]; then
echo "reading some vars from conf.cache"
@@ -100,7 +101,18 @@ do
fi
done
-
+echo "checking Erlang dependencies"
+EDEPS=`cat $ERL_LIB/DEPENDENCIES`
+for DEP in $EDEPS
+do
+ if [ -d $ERL_LIB/$DEP ]; then
+ echo "found $ERL_LIB/$DEP"
+ else
+ echo "ERROR: not found $ERL_LIB/$DEP"
+ echo "------ please copy $DEP into $ERL_LIB and try again"
+ exit 1
+ fi
+done
View
1  erl/Makefile
@@ -1,5 +1,6 @@
all:
(cd src;$(MAKE) all)
+ (cd priv/log4erl-0.9.0;$(MAKE))
(cd test;$(MAKE) all)
final: clean
View
4 erl/bin/shell
@@ -10,8 +10,10 @@ export ERL_HOME
export JAVA_HOME
export ERL_CRASH_DUMP=${SCRIPT_DIR}/erl_crash.dump
+LOG4ERL=../priv/log4erl-0.9.0/ebin
+
ERL=${ERL_HOME}/bin/erl
-ERL_FLAGS="+K true +S 1:1 -pa ${SCRIPT_DIR}/../ebin -setcookie `cat ${SCRIPT_DIR}/cookie`"
+ERL_FLAGS="+K true +S 1:1 -pa ${SCRIPT_DIR}/../ebin -pz ${LOG4ERL} -setcookie `cat ${SCRIPT_DIR}/cookie`"
NAME="shell"
View
1  erl/priv/DEPENDENCIES
@@ -0,0 +1 @@
+log4erl-0.9.0
View
6 erl/src/ej_app.erl
@@ -21,7 +21,6 @@ stop() ->
application:stop(?APPNAME).
start(Type, Args) ->
- log:info(self(), "starting; type: ~p args: ~p", [Type,Args]),
application:set_env(?APPNAME, listeners, sets:new()),
case Type of
normal -> ej_sup:start_link([]);
@@ -30,13 +29,14 @@ start(Type, Args) ->
end.
prep_stop(State) ->
- log:info(self(), "prepare stopping with state: ~p", [State]),
+ ej_log:info("prepare stopping with state: ~p", [State]),
ej_srv:stop(),
timer:sleep(1000),
ok.
stop(State) ->
- log:info(self(), "stopping with state: ~p", [State]),
+ ej_log:info("stopping with state: ~p", [State]),
+ ej_log:stop(),
ok.
getenv(K,Def) ->
View
175 erl/src/ej_log.erl
@@ -0,0 +1,175 @@
+
+%% logging interface
+%%
+%% author: ingo schramm
+
+-module(ej_log).
+-export([fatal/2, err/2, error/2, warn/2, warning/2, info/2, debug/2]).
+% gen_server exports
+-export([start/0, start_link/0, stop/0]).
+-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
+
+-export([log/5,set/2]).
+
+-author("Ingo Schramm").
+
+-include("global.hrl").
+-include_lib("eunit/include/eunit.hrl").
+
+-record(state,
+ {verbosity = verbose
+ ,f = fun(Who, Node, Level, Msg, Args) -> print_log({Who,Node}, Level, Msg, Args) end
+ }).
+
+% @doc Write a logging message.
+% @spec log(Who::pid(), Node::node(), L::Level, Msg::string(), Args::list()) -> ok
+% where
+% Level = 'FATAL' + 'ERROR' + 'WARNING' + 'INFO' + 'DEBUG'
+log(Who, Node, Level, Msg, Args) ->
+ gen_server:cast({global,?MODULE}, {Who, Node, Level, Msg, Args}).
+
+log(Level, Msg, Args) ->
+ gen_server:cast({global,?MODULE}, {self(), node(), Level, Msg, Args}).
+
+fatal(Msg, Args) ->
+ log(fatal, Msg, Args).
+
+error(Msg, Args) ->
+ err(Msg, Args).
+err(Msg, Args) ->
+ log(error, Msg, Args).
+
+warning(Msg, Args) ->
+ warn(Msg, Args).
+warn(Msg, Args) ->
+ log(warn, Msg, Args).
+
+info(Msg, Args) ->
+ log(info, Msg, Args).
+
+debug(Msg, Args) ->
+ log(debug, Msg, Args).
+
+% @doc Set a log server property.
+%
+% Avalable properties:
+% <pre>
+% verbosity - silent | verbose
+% </pre>
+%
+% @spec set(Name::atom(), Value::any()) -> ok
+set(verbosity, silent) ->
+ gen_server:cast({global,?MODULE}, {set, {verbosity, silent}});
+set(verbosity, verbose) ->
+ gen_server:cast({global,?MODULE}, {set, {verbosity, verbose}}).
+
+% @doc Start the global log server.
+% @spec start() -> {ok, Pid::pid()} | {error, Reason::any()}
+start() ->
+ start_link().
+
+% @hidden
+start_link() ->
+ gen_server:start_link({global, ?MODULE}, ?MODULE, #state{}, []).
+
+% @doc Stop the global log server.
+% @spec stop() -> ok
+stop() ->
+ gen_server:cast({global, ?MODULE},{'STOP'}),
+ global:unregister_name(?MODULE).
+
+% @hidden
+init(State) ->
+ S1 =
+ case has_log4erl() of
+ true ->
+ log4erl:add_file_appender(file, {"../log", "ej_erl", {size, 100000}, 4, "log", debug}),
+ log4erl:change_format(file1, "[%L] %j %T %l%n"),
+ State#state{f = fun(Who, Node, Level, Msg, Args) -> log4(Who, Node, Level, Msg, Args) end};
+ false -> State
+ end,
+ info("logger is working", []),
+ {ok,S1}.
+
+% @hidden
+handle_call({Who, Level, Msg, Args},_From,State) ->
+ log:print_log(Who, Level, Msg, Args),
+ {noreply, State}.
+
+% @hidden
+handle_cast({Who, Node, Level, Msg, Args}, State) ->
+ case State#state.verbosity of
+ %verbose -> log:print_log({Who,Node}, Level, Msg, Args);
+ verbose -> F = State#state.f,
+ F(Who, Node, Level, Msg, Args);
+ _Any -> ok
+ end,
+ {noreply, State};
+handle_cast({set, {K,V}},State) ->
+ NewState =
+ case K of
+ verbosity -> State#state{verbosity = V};
+ _Any -> State
+ end,
+ {noreply, NewState};
+handle_cast({'STOP'}, State) ->
+ log:info(self(),"stopping with state: ~p", [State]),
+ {stop, normal, State};
+handle_cast(Msg,State) ->
+ log:print_log(self(), 'ERROR', "log_srv cannot understand: ~p", [Msg]),
+ {noreply, State}.
+
+% @hidden
+handle_info(_Msg,State) ->
+ {noreply, State}.
+
+% @hidden
+terminate(_Reason,State) ->
+ {noreply, State}.
+
+% @hidden
+code_change(_OldVsn, State, _Extra) ->
+ {ok, State}.
+
+
+%% ----- PRIVATE PARTS -----
+
+print_log(Who, Level, Msg, Args) ->
+ {Year, Month, Day} = erlang:date(),
+ {Hour, Minute, Second} = erlang:time(),
+ {_Megas, _Secs, Micros} = erlang:now(),
+ List = [Level,Year,Month,Day,Hour,Minute,Second,Micros,Who|Args],
+ io:format("~p ~p/~p/~p-~p:~p:~p.~p ~p -> " ++ Msg ++ "~n", List).
+
+log4(Who, Node, Level, Msg, Args) ->
+ List = [{Who, Node}|Args],
+ log4erl:log(Level, " ~p -> " ++ Msg, List).
+
+has_log4erl() ->
+ case lists:keyfind(log4erl, 1, application:which_applications()) of
+ false -> false;
+ {log4erl, _, _} -> true
+ end.
+
+%% ----- TESTS -----
+
+start_stop_test() ->
+ start(),
+ timer:sleep(100),
+ stop(),
+ start(),
+ timer:sleep(100),
+ stop().
+
+
+
+
+
+
+
+
+
+
+
+
+
View
64 erl/src/ej_srv.erl
@@ -140,7 +140,7 @@ init(S) ->
yes -> S;
no -> initialize(S)
end,
- log:info(self(), "~w initialized with state ~w", [?MODULE, S1]),
+ %ej_ej_log:info("~w initialized with state ~w", [?MODULE, S1]),
{ok,S1}.
% @hidden
@@ -165,7 +165,7 @@ handle_call({bad},_From,S) ->
erlang:foobar(),
{noreply,S};
handle_call(Msg,From,S) ->
- log:warn(self(), "Cannot understand call from ~w: ~w", [From,Msg]),
+ ej_log:warn("Cannot understand call from ~w: ~w", [From,Msg]),
{reply, {error, unknown_msg}, S}.
% @hidden
@@ -174,10 +174,10 @@ handle_cast({send,From,Ref,Tag,Msg}, S) ->
gen_server:reply(From, Result),
{noreply, S};
handle_cast({set_peer, Peer}, S) ->
- log:debug(self(), "replacing peer ~p with ~p: ", [S#ej.peer, Peer]),
+ ej_log:debug("replacing peer ~p with ~p: ", [S#ej.peer, Peer]),
{noreply, S#ej{peer=Peer}};
handle_cast({callback, Ref, Tag, Msg}, S) ->
- log:debug(self(), "callback: ~p", [Ref]),
+ ej_log:debug("callback: ~p", [Ref]),
send_peer(S#ej.peer,Ref,Tag,Msg),
{noreply,S};
handle_cast({'STOP'}, S) ->
@@ -185,10 +185,10 @@ handle_cast({'STOP'}, S) ->
yes -> nop;
no -> shutdown(S#ej.peer,S)
end,
- log:info(self(),"stopping with state: ~w", [S]),
+ ej_log:info("stopping with state: ~w", [S]),
{noreply, S#ej{stopping=true}};
handle_cast(Msg,S) ->
- log:info(self(),"cannot handle cast: ~w", [Msg]),
+ ej_log:info("cannot handle cast: ~w", [Msg]),
{noreply, S}.
% @hidden
@@ -196,17 +196,17 @@ handle_cast(Msg,S) ->
handle_info({Port,{data,"\n"}},S) when is_port(Port) ->
{noreply,S};
handle_info({Port,{data,Msg}},S) when is_port(Port) ->
- log:info(self(),"port says: ~p", [Msg]),
+ ej_log:info("port says: ~p", [Msg]),
{noreply,S};
% ej_srv messages
handle_info({From,notify_start}, S) ->
notify_listeners(start),
{noreply,S};
handle_info({From,_Ref,{?TAG_OK,[?EJMSGPART(call,handshake)]}},S) ->
- log:debug(self(), "info handshake from: ~w", [From]),
+ ej_log:debug("info handshake from: ~w", [From]),
{noreply, populate_peer(From,S)};
handle_info(Msg={'EXIT', Pid, Reason},S) ->
- log:warn(self(), "EXIT from ~w with reason: ~w", [Pid,Reason]),
+ ej_log:warn("EXIT from ~w with reason: ~w", [Pid,Reason]),
S1 =
case is_port(Pid) of
true -> S;
@@ -216,29 +216,29 @@ handle_info(Msg={'EXIT', Pid, Reason},S) ->
handle_info({'STOP'},S) ->
case S#ej.worker of
yes ->
- log:info(self(),"stopping with state: ~w", [S]),
+ ej_log:info("stopping with state: ~w", [S]),
{stop, normal, S};
no ->
{noreply,S}
end;
% messages to be routed to client
handle_info({From,Ref={Client,_Id},M={?TAG_FRAGMENT,Msg}},S) ->
- log:debug(self(), "got fragment: From=~w Ref=~w Msg=~w", [From,Ref,M]),
+ ej_log:debug("got fragment: From=~w Ref=~w Msg=~w", [From,Ref,M]),
if
- Client =:= self() -> log:error(self(), "possible message loop", []);
+ Client =:= self() -> ej_log:error("possible message loop", []);
true -> Client ! {self(),Ref,Msg}
end,
{noreply, S};
handle_info({From,Ref={Client,_Id},Msg},S) ->
- log:debug(self(), "got result: From=~w Ref=~w Msg=~w", [From,Ref,Msg]),
+ ej_log:debug("got result: From=~w Ref=~w Msg=~w", [From,Ref,Msg]),
if
- Client =:= self() -> log:error(self(), "possible message loop", []);
+ Client =:= self() -> ej_log:error("possible message loop", []);
true -> Client ! {self(),Ref,Msg}
end,
{noreply, S};
% unknown
handle_info(Msg,S) ->
- log:info(self(),"info: ~p", [Msg]),
+ ej_log:info(self(),"info: ~p", [Msg]),
{noreply,S}.
% @hidden
@@ -253,7 +253,7 @@ code_change(_OldVsn, S, _Extra) ->
%% ------ PRIVATE -----
send_peer(Peer,Ref,Tag,Msg) ->
- log:debug(self(), "send_peer ~w: ~w", [Peer,?EJMSG(Ref,Tag,Msg)]),
+ ej_log:debug("send_peer ~w: ~w", [Peer,?EJMSG(Ref,Tag,Msg)]),
Peer ! ?EJMSG(Ref,Tag,Msg).
start_worker(S) ->
@@ -291,19 +291,19 @@ handshake(Bindir) ->
case send_ping(Pid) of
pong -> Pid;
Error ->
- log:error(self(), "peer not reachable: ~w", [Error]),
+ ej_log:error("peer not reachable: ~w", [Error]),
throw({peer_does_not_answer,Error})
end.
quick_handshake(Peer) ->
- log:info(self(), "quick handshake to: ~w", [Peer]),
+ ej_log:info("quick handshake to: ~w", [Peer]),
run_handshake(Peer).
% TODO we should retry handshake after opening port
% for at least 3 times to allow first JVM startup ever
% to be a little slower (not yet cached in the OS)
full_handshake(Peer,Bindir) ->
- log:info(self(), "full handshake to: ~w", [Peer]),
+ ej_log:info("full handshake to: ~w", [Peer]),
port(Bindir),
timer:sleep(500),
case run_handshake(Peer) of
@@ -317,33 +317,39 @@ port(Bindir) ->
++ " -sname " ++ ?PEERSTR
++ " -cookie " ++ atom_to_list(erlang:get_cookie()),
Cmd = Bindir ++ "/" ++ ?JNODEBIN ++ " " ++ Args ++ " &",
- log:info(self(), "open port to org.ister.ej.Node: ~p", [Cmd]),
+ ej_log:info("open port to org.ister.ej.Node: ~p", [Cmd]),
Port = erlang:open_port({spawn, Cmd},[stderr_to_stdout]),
- log:info(self(), "port: ~w", [Port]).
+ ej_log:info("port: ~w", [Port]).
run_handshake(Peer) ->
send_peer(Peer, Ref=get_ref(), ?TAG_NODE, [?EJMSGPART(call,handshake)]),
receive
{From,Ref,{?TAG_OK,[?EJMSGPART(call,handshake)]}} ->
- log:info(self(), "got handshake from: ~w", [From]),
+ ej_log:info("got handshake from: ~w", [From]),
erlang:link(From),
{ok,From}
after
?BLOCKING_TIMEOUT ->
- log:info(self(), "handshake timeout", []),
+ ej_log:info("handshake timeout", []),
{error,no_answer}
end.
notify_listeners(What) ->
- {ok, Listeners} = application:get_env(listeners),
+ Listeners = get_listeners(),
case sets:is_set(Listeners) of
true ->
L2 = sets:to_list(Listeners),
- log:debug(self(), "About to send notification '~p' to listeners: ~p", [What,L2]),
+ ej_log:debug("About to send notification '~p' to listeners: ~p", [What,L2]),
lists:map(
fun(Pid) -> Pid ! {self(), ej_notify, What} end, L2);
false ->
- log:error(self(), "not a set ~p", [Listeners])
+ ej_log:error("not a set ~p", [Listeners])
+ end.
+
+get_listeners() ->
+ case application:get_env(listeners) of
+ {ok, Ls} -> Ls;
+ Any -> []
end.
shutdown(Peer,S) ->
@@ -355,11 +361,11 @@ shutdown_peer(Peer) ->
send_peer(Peer, Ref=get_ref(), ?TAG_NODE, [?EJMSGPART(call,shutdown)]),
receive
{Peer,Ref,{?TAG_OK,[?EJMSGPART(call,bye)]}} ->
- log:info(self(), "shutdown confirmed by peer", []),
+ ej_log:info("shutdown confirmed by peer", []),
ok
after
?BLOCKING_TIMEOUT ->
- log:error(self(), "shutdown timeout: no ok from peer", []),
+ ej_log:error("shutdown timeout: no ok from peer", []),
well
end.
@@ -371,7 +377,7 @@ handle_exit({'EXIT', Peer, noconnection}, S) when Peer =:= S#ej.peer ->
populate_peer(NewPeer,S)
end;
handle_exit(Any,S) ->
- log:debug(self(), "don't know how to handle exit: ~w", [Any]),
+ ej_log:debug("don't know how to handle exit: ~w", [Any]),
S.
send_ping(Peer) ->
View
23 erl/src/ej_sup.erl
@@ -16,17 +16,19 @@ start_link(Args) when is_list(Args) ->
supervisor:start_link({local,?MODULE}, ?MODULE, [Args]).
init(Args = [_|_]) ->
- log:info(self(), "initializing supervisor '~p' with Args: ~w", [?MODULE, Args]),
+ %log:info(self(), "initializing supervisor '~p' with Args: ~w", [?MODULE, Args]),
[SrvArgs|_] = Args,
Spec =
- {ok,{{one_for_one,10,10},
- [get_spec(SrvArgs)]
+ {ok,{{one_for_all,10,10},
+ [get_log_spec()
+ ,get_ej_spec(SrvArgs)
+ ]
}},
- log:debug(self(), "child spec: ~w", [Spec]),
+ %log:debug(self(), "child spec: ~w", [Spec]),
Spec.
-get_spec(SrvArgs) ->
- {reducer_sup
+get_ej_spec(SrvArgs) ->
+ {ej_srv
,{ej_srv, start_link, SrvArgs}
,transient % or permanent?
,5000
@@ -34,7 +36,14 @@ get_spec(SrvArgs) ->
,[ej_srv]
}.
-
+get_log_spec() ->
+ {ej_log
+ ,{ej_log, start_link, []}
+ ,transient % or permanent?
+ ,5000
+ ,worker
+ ,[ej_log]
+ }.
%% ----- TESTS -----
View
49 erl/src/log.erl
@@ -1,49 +0,0 @@
-%% @doc simple logging
-%%
-%% @author Ingo Schramm
-
--module(log).
-
--export([fatal/3, err/3, error/3, warn/3, warning/3, info/3, debug/3, print_log/4, do_log/4]).
-
--author("Ingo Schramm").
-
--include("global.hrl").
--include_lib("eunit/include/eunit.hrl").
-
-
-fatal(Who, Msg, Args) ->
- do_log(Who, 'FATAL', Msg, Args).
-
-error(Who, Msg, Args) ->
- err(Who, Msg, Args).
-err(Who, Msg, Args) ->
- do_log(Who, 'ERROR', Msg, Args).
-
-warning(Who, Msg, Args) ->
- warn(Who, Msg, Args).
-warn(Who, Msg, Args) ->
- do_log(Who, 'WARNING', Msg, Args).
-
-info(Who, Msg, Args) ->
- do_log(Who, 'INFO', Msg, Args).
-
-debug(Who, Msg, Args) ->
- do_log(Who, 'DEBUG', Msg, Args).
-
-%% ----- PRIVATE PARTS -----
-
-% may also use error_logger
-
-do_log(Who, Level, Msg, Args) ->
- case global:whereis_name(log_srv) of
- undefined -> print_log(Who, Level, Msg, Args);
- _Pid -> log_srv:log(Who, node(), Level, Msg, Args)
- end.
-
-print_log(Who, Level, Msg, Args) ->
- {Year, Month, Day} = erlang:date(),
- {Hour, Minute, Second} = erlang:time(),
- {_Megas, _Secs, Micros} = erlang:now(),
- List = [Level,Year,Month,Day,Hour,Minute,Second,Micros,Who|Args],
- io:format("~p ~p/~p/~p-~p:~p:~p.~p ~p -> " ++ Msg ++ "~n", List).
View
14 erl/src/neo4j.erl
@@ -311,3 +311,17 @@ get_other_nodes(Id,Edges) ->
end,
Edges).
+
+%% ------ TESTS ------
+
+start_test() ->
+ ej_srv:start(1,"../bin"),
+ R = ?MODULE:start(),
+ timer:sleep(300),
+ ?assertEqual(R, ok).
+
+stop_test() ->
+ R = ?MODULE:stop(),
+ ?assertEqual(R, ok),
+ ej_srv:stop().
+
View
6 erl/src/neo4j_app.erl
@@ -21,7 +21,7 @@ stop() ->
application:stop(?APPNAME).
start(Type, Args) ->
- log:info(self(), "starting; type: ~p args: ~p", [Type,Args]),
+ ej_log:info("starting; type: ~p args: ~p", [Type,Args]),
case Type of
normal -> neo4j_sup:start_link([]);
takeover -> ok;
@@ -29,13 +29,13 @@ start(Type, Args) ->
end.
prep_stop(State) ->
- log:info(self(), "prepare stopping with state: ~p", [State]),
+ ej_log:info("prepare stopping with state: ~p", [State]),
neo4j_srv:stop(),
timer:sleep(1000),
ok.
stop(State) ->
- log:info(self(), "stopping with state: ~p", [State]),
+ ej_log:info("stopping with state: ~p", [State]),
ok.
getenv(K,Def) ->
View
22 erl/src/neo4j_srv.erl
@@ -55,12 +55,12 @@ init(S) ->
yes -> S;
no -> initialize(S)
end,
- log:info(self(), "~w initialized with state ~w", [?MODULE, S1]),
+ ej_log:info("~w initialized with state ~w", [?MODULE, S1]),
{ok,S1}.
% @hidden
handle_call(Msg,From,S) ->
- log:warn(self(), "Cannot understand call from ~w: ~w", [From,Msg]),
+ ej_log:warn("Cannot understand call from ~w: ~w", [From,Msg]),
{reply, {error, unknown_msg}, S}.
% @hidden
@@ -69,20 +69,20 @@ handle_cast({'STOP'}, S) ->
yes -> nop;
no -> shutdown(S)
end,
- log:info(self(),"stopping with state: ~w", [S]),
+ ej_log:info("stopping with state: ~w", [S]),
{stop, normal, S};
handle_cast(Msg,S) ->
- log:info(self(),"cannot handle cast: ~w", [Msg]),
+ ej_log:info("cannot handle cast: ~w", [Msg]),
{noreply, S}.
% @hidden
handle_info(Msg={From, ej_notify, start}, S) ->
- log:debug(self(), "got notification: ~p", [Msg]),
+ ej_log:debug("got notification: ~p", [Msg]),
timer:sleep(100),
neo4j:start(),
{noreply, S};
handle_info(Msg={From, ej_notify, stop}, S) ->
- log:debug(self(), "got notification: ~p", [Msg]),
+ ej_log:debug("got notification: ~p", [Msg]),
erlang:send_after(50, self(), {'STOP'}),
{noreply, S};
handle_info({'STOP'}, S) ->
@@ -90,10 +90,10 @@ handle_info({'STOP'}, S) ->
yes -> nop;
no -> shutdown(S)
end,
- log:info(self(),"stopping with state: ~w", [S]),
+ ej_log:info("stopping with state: ~w", [S]),
{stop, normal, S};
handle_info(Msg,S) ->
- log:info(self(),"info: ~p", [Msg]),
+ ej_log:info("info: ~p", [Msg]),
{noreply,S}.
% @hidden
@@ -114,15 +114,15 @@ initialize(S) ->
S1 =
case catch(neo4j:start()) of
{'EXIT',Reason} ->
- log:error(self(), "starting neo4j failed: ~w", [Reason]),
+ ej_log:error("starting neo4j failed: ~w", [Reason]),
S;
Msg ->
- log:debug(self(), "~p", [Msg]),
+ ej_log:debug("~p", [Msg]),
case neo4j:has_db() of
true ->
S#neo4j{db=true};
false ->
- log:error(self(), "no database available", []),
+ ej_log:error("no database available", []),
erlang:send_after(100, self(), {'STOP'}),
S#neo4j{db=false}
end
View
4 erl/src/neo4j_sup.erl
@@ -16,13 +16,13 @@ start_link(Args) when is_list(Args) ->
supervisor:start_link({local,?MODULE}, ?MODULE, [Args]).
init(Args = [_|_]) ->
- log:info(self(), "initializing supervisor '~p' with Args: ~w", [?MODULE, Args]),
+ ej_log:info("initializing supervisor '~p' with Args: ~w", [?MODULE, Args]),
[SrvArgs|_] = Args,
Spec =
{ok,{{one_for_one,10,10},
[get_spec(SrvArgs)]
}},
- log:debug(self(), "child spec: ~w", [Spec]),
+ ej_log:debug("child spec: ~w", [Spec]),
Spec.
get_spec(SrvArgs) ->
Please sign in to comment.
Something went wrong with that request. Please try again.