diff options
author | Péter Dimitrov <[email protected]> | 2018-06-18 15:19:09 +0200 |
---|---|---|
committer | Péter Dimitrov <[email protected]> | 2018-06-20 15:18:37 +0200 |
commit | 41a71f54b2da01bc532d0c2d16c691e6622817ca (patch) | |
tree | dcf63263149b40328a5c424e180634079e6f6868 /lib/ssl/src | |
parent | 3c3d2d8b14501b4b279deae643490f92f98a99d5 (diff) | |
download | otp-41a71f54b2da01bc532d0c2d16c691e6622817ca.tar.gz otp-41a71f54b2da01bc532d0c2d16c691e6622817ca.tar.bz2 otp-41a71f54b2da01bc532d0c2d16c691e6622817ca.zip |
ssl: Add set_log_level/1
- Add utility function for setting log level of ssl application
modules.
Change-Id: Iee278ada17b4d872a9891094b96ce5343bf0ade4
Diffstat (limited to 'lib/ssl/src')
-rw-r--r-- | lib/ssl/src/ssl.erl | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/ssl/src/ssl.erl b/lib/ssl/src/ssl.erl index 592c02a28c..9cf2b8acb0 100644 --- a/lib/ssl/src/ssl.erl +++ b/lib/ssl/src/ssl.erl @@ -55,7 +55,8 @@ format_error/1, renegotiate/1, prf/5, negotiated_protocol/1, connection_information/1, connection_information/2]). %% Misc --export([handle_options/2, tls_version/1, new_ssl_options/3, suite_to_str/1]). +-export([handle_options/2, tls_version/1, new_ssl_options/3, suite_to_str/1, + set_log_level/1]). -deprecated({ssl_accept, 1, eventually}). -deprecated({ssl_accept, 2, eventually}). @@ -801,6 +802,32 @@ suite_to_str(Cipher) -> ssl_cipher:suite_to_str(Cipher). +%%-------------------------------------------------------------------- +-spec set_log_level(atom()) -> ok | {error, term()}. +%% +%% Description: Set log level for the SSL application +%%-------------------------------------------------------------------- +set_log_level(Level) -> + case application:get_all_key(ssl) of + {ok, PropList} -> + Modules = proplists:get_value(modules, PropList), + set_module_level(Modules, Level); + undefined -> + {error, ssl_not_started} + end. + +set_module_level(Modules, Level) -> + Fun = fun (Module) -> + ok = logger:set_module_level(Module, Level) + end, + try lists:map(Fun, Modules) of + _ -> + ok + catch + error:{badmatch, Error} -> + Error + end. + %%%-------------------------------------------------------------- %%% Internal functions %%%-------------------------------------------------------------------- |