Commits

Anonymous committed f229162

Adding 'enable_webmachine_logger' option.

This option is intended for the webmachine_mochiweb:init/1 function.
This makes it possible to control if the webmachine_logger shouold
be started or not. Thus, your supervisor could look something like:

init([]) ->

{ok, Dispatch} = file:consult(filename:join([tt_app:get_base_dir(),
"priv", "dispatch.conf"])),

Options = [{log_dir, tt_app:get_env(log_dir, "priv/log")},
{enable_webmachine_logger, true},
{enable_perf_logger, true},
{dispatch, Dispatch}],

webmachine_mochiweb:init(Options),

MochiOptions = [],
Wspecs = [webmachine_mochiweb:worker_childspec(WebConfig) ||
WebConfig <- webmachine_mochiweb:setup_the_mochiweb_options(MochiOptions,
Dispatch)],

{ok, {{one_for_one, 10, 10}, Wspecs}}.

Comments (0)

Files changed (1)

src/webmachine_mochiweb.erl

     {DispatchList, Options1} = get_option(dispatch, Options),
     {ErrorHandler0, Options2} = get_option(error_handler, Options1),
     {EnablePerfLog, Options3} = get_option(enable_perf_logger, Options2),
+    {EnableWebmLogger, Options4} = get_option(enable_webmachine_logger, Options3),
+    case EnableWebmLogger of
+        true -> application:set_env(webmachine, webmachine_logger_module, webmachine_logger);
+        _    -> false
+    end,
     ErrorHandler = 
 	case ErrorHandler0 of 
 	    undefined ->
 		webmachine_error_handler;
 	    EH -> EH
 	end,
-    {LogDir, _Options4} = get_option(log_dir, Options3),
+    {LogDir, _Options5} = get_option(log_dir, Options4),
     webmachine_sup:start_logger(LogDir),
     case EnablePerfLog of
 	true ->