From 2187b54499a280fdf92e8832a5126cadeb9cd610 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 29 Apr 2011 17:14:12 +0200 Subject: Fail sasl startup if some, but not all, environment variables related to log_mf_h are given The sasl application starts and adds log_mf_h handler if all three environment variables are given and valid. If any of the variables are invalid, sasl startup will crash. Earlier, if one or two of the variables were missing sasl would successfully start but silently skip adding log_mf_h. This commit changes this behaviour so that sasl startup will crash if some variables are given and some are not. --- lib/sasl/doc/src/sasl_app.xml | 7 ++++++- lib/sasl/src/sasl.erl | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/sasl/doc/src/sasl_app.xml b/lib/sasl/doc/src/sasl_app.xml index a7fecfc440..446baccb08 100644 --- a/lib/sasl/doc/src/sasl_app.xml +++ b/lib/sasl/doc/src/sasl_app.xml @@ -4,7 +4,7 @@
- 19962009 + 19962011 Ericsson AB. All Rights Reserved. @@ -67,6 +67,11 @@

This error logger writes all events sent to the error logger to disk. It installs the log_mf_h event handler in the error_logger process.

+

To activate this event handler, the following three sasl + configuration parameters must be set: + error_logger_mf_dir, error_logger_mf_maxbytes + and error_logger_mf_maxfiles. See below for more + information about the configuration parameters.

diff --git a/lib/sasl/src/sasl.erl b/lib/sasl/src/sasl.erl index d1babaffff..aed5f0da1f 100644 --- a/lib/sasl/src/sasl.erl +++ b/lib/sasl/src/sasl.erl @@ -81,27 +81,38 @@ get_mf() -> Dir = get_mf_dir(), MaxB = get_mf_maxb(), MaxF = get_mf_maxf(), - {Dir, MaxB, MaxF}. + case {Dir, MaxB, MaxF} of + {undefined,undefined,undefined} = R -> + R; + {undefined,_,_} -> + exit({missing_config, {sasl, error_logger_mf_dir}}); + {_,undefined,_} -> + exit({missing_config, {sasl, error_logger_mf_maxbytes}}); + {_,_,undefined} -> + exit({missing_config, {sasl, error_logger_mf_maxfiles}}); + R -> + R + end. get_mf_dir() -> case application:get_env(sasl, error_logger_mf_dir) of - {ok, false} -> throw(undefined); + {ok, false} -> undefined; {ok, Dir} when is_list(Dir) -> Dir; - undefined -> throw(undefined); + undefined -> undefined; {ok, Bad} -> exit({bad_config, {sasl, {error_logger_mf_dir, Bad}}}) end. get_mf_maxb() -> case application:get_env(sasl, error_logger_mf_maxbytes) of {ok, MaxB} when is_integer(MaxB) -> MaxB; - undefined -> throw(undefined); + undefined -> undefined; {ok, Bad} -> exit({bad_config, {sasl, {error_logger_mf_maxbytes, Bad}}}) end. get_mf_maxf() -> case application:get_env(sasl, error_logger_mf_maxfiles) of {ok, MaxF} when is_integer(MaxF), MaxF > 0, MaxF < 256 -> MaxF; - undefined -> throw(undefined); + undefined -> undefined; {ok, Bad} -> exit({bad_config, {sasl, {error_logger_mf_maxfiles, Bad}}}) end. -- cgit v1.2.3