]> granicus.if.org Git - ejabberd/commitdiff
* src/ejabberd_app.erl: Open ejabberd.log sooner, so errors during
authorBadlop <badlop@process-one.net>
Fri, 24 Oct 2008 22:07:38 +0000 (22:07 +0000)
committerBadlop <badlop@process-one.net>
Fri, 24 Oct 2008 22:07:38 +0000 (22:07 +0000)
ejabberd initialization are logged in that file (EJAB-777). Write
a log message when ejabberd finishes the start or stop.

SVN Revision: 1667

ChangeLog
src/ejabberd_app.erl

index 4e5eaa2d6846457991f118ed48f49f16409369e2..c1f0a4d92b8d4100fa358ab83999e1182107c999 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-10-25  Badlop  <badlop@process-one.net>
+
+       * src/ejabberd_app.erl: Open ejabberd.log sooner, so errors during
+       ejabberd initialization are logged in that file (EJAB-777). Write
+       a log message when ejabberd finishes the start or stop.
+
 2008-10-24  Badlop  <badlop@process-one.net>
 
        * src/ejabberd_c2s.erl: Ensure unique ID in roster push (EJAB-721)
index 50f8a44fe47e133345505e12d298b4e381caa57e..5f385586ee0dd0e4748f325dc34a420fb21e53bc 100644 (file)
@@ -29,7 +29,7 @@
 
 -behaviour(application).
 
--export([start_modules/0,start/2, prep_stop/1, stop/1, init/0]).
+-export([start_modules/0,start/2, get_log_path/0, prep_stop/1, stop/1, init/0]).
 
 -include("ejabberd.hrl").
 
@@ -45,6 +45,7 @@ start(normal, _Args) ->
     db_init(),
     sha:start(),
     stringprep_sup:start_link(),
+    start(),
     translate:start(),
     acl:start(),
     ejabberd_ctl:init(),
@@ -53,7 +54,6 @@ start(normal, _Args) ->
     gen_mod:start(),
     ejabberd_config:start(),
     ejabberd_check:config(),
-    start(),
     connect_nodes(),
     Sup = ejabberd_sup:start_link(),
     ejabberd_rdbms:start(),
@@ -65,12 +65,13 @@ start(normal, _Args) ->
     %fprof:trace(start, "/tmp/fprof"),
     start_modules(),
     ejabberd_listener:start_listeners(),
+    ?INFO_MSG("ejabberd ~s is started in the node ~p", [?VERSION, node()]),
     Sup;
 start(_, _) ->
     {error, badarg}.
 
 %% Prepare the application for termination.
-%% This function is called when an application is about to be stopped, 
+%% This function is called when an application is about to be stopped,
 %% before shutting down the processes of the application.
 prep_stop(State) ->
     stop_modules(),
@@ -79,6 +80,7 @@ prep_stop(State) ->
 
 %% All the processes were killed when this function is called
 stop(_State) ->
+    ?INFO_MSG("ejabberd ~s is stopped in the node ~p", [?VERSION, node()]),
     ok.
 
 
@@ -93,18 +95,7 @@ init() ->
     register(ejabberd, self()),
     %erlang:system_flag(fullsweep_after, 0),
     %error_logger:logfile({open, ?LOG_PATH}),
-    LogPath =
-       case application:get_env(log_path) of
-            {ok, Path} ->
-               Path;
-           undefined ->
-               case os:getenv("EJABBERD_LOG_PATH") of
-                   false ->
-                       ?LOG_PATH;
-                   Path ->
-                       Path
-               end
-       end,
+    LogPath = get_log_path(),
     error_logger:add_report_handler(ejabberd_logger_h, LogPath),
     erl_ddll:load_driver(ejabberd:get_so_path(), tls_drv),
     case erl_ddll:load_driver(ejabberd:get_so_path(), expat_erl) of
@@ -171,3 +162,21 @@ connect_nodes() ->
                          end, Nodes)
     end.
 
+%% @spec () -> string()
+%% Returns the full path to the ejabberd log file.
+%% It first checks for application configuration parameter 'log_path'.
+%% If not defined it checks the environment variable EJABBERD_LOG_PATH.
+%% And if that one is neither defined, returns the default value:
+%% "ejabberd.log" in current directory.
+get_log_path() ->
+    case application:get_env(log_path) of
+       {ok, Path} ->
+           Path;
+       undefined ->
+           case os:getenv("EJABBERD_LOG_PATH") of
+               false ->
+                   ?LOG_PATH;
+               Path ->
+                   Path
+           end
+    end.