Details

      Description

      This patch adds sasl.log rotation to the processing of "reopen-log" command, the idea is taken from the erlware.org/ewlib/ewl_elwrap_h.erl
      Not sure if it is of great importance, as sasl.log doesn't typically grow when ejabberd is running, but I still find it useful.

      diff -urN ejabberd-2.0.1/src/ejabberd_ctl.erl ejabberd-2.0.1.sasl_reopen/src/ejabberd_ctl.erl
      --- ejabberd-2.0.1/src/ejabberd_ctl.erl	2008-05-20 13:22:03.000000000 +0300
      +++ ejabberd-2.0.1.sasl_reopen/src/ejabberd_ctl.erl	2008-08-04 11:22:12.000000000 +0300
      @@ -98,6 +98,13 @@
       
       process(["reopen-log"]) ->
           ejabberd_logger_h:reopen_log(),
      +    case application:get_env(sasl,sasl_error_logger) of
      +	{ok, {file, SASLfile}} ->
      +	    error_logger:delete_report_handler(sasl_report_file_h),
      +	    error_logger:add_report_handler(sasl_report_file_h,
      +	        {SASLfile, get_sasl_error_logger_type()});
      +	_ -> false
      +	end,
           ?STATUS_SUCCESS;
       
       process(["register", User, Server, Password]) ->
      @@ -400,3 +407,15 @@
       		     fun() -> mnesia:match_object(T, W, read) end),
           lists:foreach(
             fun(Term) -> io:format(F,"~p.~n", [setelement(1, Term, T)]) end, All).
      +
      +%%--------------------------------------------------------------------
      +%% copied from lib/sasl/src/sasl.erl which did not export it
      +
      +get_sasl_error_logger_type () ->
      +    case application:get_env (sasl, errlog_type) of
      +	{ok, error} -> error;
      +	{ok, progress} -> progress;
      +	{ok, all} -> all;
      +	{ok, Bad} -> exit ({bad_config, {sasl, {errlog_type, Bad}}});
      +	_ -> all
      +    end.
      

        Activity

        Hide
        badlop Badlop added a comment -

        When this patch is committed, the explanation in ejabberd Guide could be improved, for example with this text:

        7.1 Log Files

        ...

        The log files grow continually, so it is recommended to rotate them periodically. To rotate the log files, rename the files and then reopen them. The ejabberd command reopen-log (see section 4.1.1) reopens the log files, and also renames the old ones if you didn't rename them.

        4.1.1 Commands

        ...

        reopen-log
        Reopen the log files after they were renamed. If the old files were not renamed before calling this command, they are automatically renamed to "*-old.log". See section 7.1.

        Show
        badlop Badlop added a comment - When this patch is committed, the explanation in ejabberd Guide could be improved, for example with this text: 7.1 Log Files ... The log files grow continually, so it is recommended to rotate them periodically. To rotate the log files, rename the files and then reopen them. The ejabberd command reopen-log (see section 4.1.1) reopens the log files, and also renames the old ones if you didn't rename them. 4.1.1 Commands ... reopen-log Reopen the log files after they were renamed. If the old files were not renamed before calling this command, they are automatically renamed to "*-old.log". See section 7.1.
        Hide
        badlop Badlop added a comment -

        Explanation in Guide added to trunk in SVN r1732 and 2.0.x branch in r1733.

        Show
        badlop Badlop added a comment - Explanation in Guide added to trunk in SVN r1732 and 2.0.x branch in r1733.

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development