aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Dimitrov <[email protected]>2018-05-16 11:01:34 +0200
committerPéter Dimitrov <[email protected]>2018-06-20 15:18:37 +0200
commitdeaadf9e82cee43a3bbc5185e811153f455b9669 (patch)
tree1f700eda56c1468b12c98dcf627260b0a9322a1b
parent0360e26f440e2f1ce81eb286e3ba657a56f666d5 (diff)
downloadotp-deaadf9e82cee43a3bbc5185e811153f455b9669.tar.gz
otp-deaadf9e82cee43a3bbc5185e811153f455b9669.tar.bz2
otp-deaadf9e82cee43a3bbc5185e811153f455b9669.zip
ssl: Add initial ssl log formatter
Change-Id: I649a686ee72fa8bbe1e1dbc44ed5ec2df9662b10
-rw-r--r--lib/ssl/src/Makefile3
-rw-r--r--lib/ssl/src/logger_ssl_formatter.erl26
-rw-r--r--lib/ssl/src/ssl.app.src2
-rw-r--r--lib/ssl/src/ssl.erl1
-rw-r--r--lib/ssl/src/ssl_app.erl17
5 files changed, 48 insertions, 1 deletions
diff --git a/lib/ssl/src/Makefile b/lib/ssl/src/Makefile
index 0d4eb2212a..335e1c55c3 100644
--- a/lib/ssl/src/Makefile
+++ b/lib/ssl/src/Makefile
@@ -86,7 +86,8 @@ MODULES= \
ssl_record \
ssl_v3 \
tls_v1 \
- dtls_v1
+ dtls_v1 \
+ logger_ssl_formatter
INTERNAL_HRL_FILES = \
ssl_alert.hrl ssl_cipher.hrl \
diff --git a/lib/ssl/src/logger_ssl_formatter.erl b/lib/ssl/src/logger_ssl_formatter.erl
new file mode 100644
index 0000000000..b17100c1f5
--- /dev/null
+++ b/lib/ssl/src/logger_ssl_formatter.erl
@@ -0,0 +1,26 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1999-2017. All Rights Reserved.
+%%
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+-module(logger_ssl_formatter).
+
+-export([format/2]).
+
+format(Log, Extra) ->
+ logger_formatter:format(Log, Extra).
diff --git a/lib/ssl/src/ssl.app.src b/lib/ssl/src/ssl.app.src
index da281829cb..e71d9565a9 100644
--- a/lib/ssl/src/ssl.app.src
+++ b/lib/ssl/src/ssl.app.src
@@ -51,6 +51,8 @@
ssl_crl_cache,
ssl_crl_cache_api,
ssl_crl_hash_dir,
+ %% Logging
+ logger_ssl_formatter,
%% App structure
ssl_app,
ssl_sup,
diff --git a/lib/ssl/src/ssl.erl b/lib/ssl/src/ssl.erl
index 0f13b737ab..a93695fb7a 100644
--- a/lib/ssl/src/ssl.erl
+++ b/lib/ssl/src/ssl.erl
@@ -87,6 +87,7 @@ stop() ->
application:stop(ssl).
%%--------------------------------------------------------------------
+
-spec connect(host() | port(), [connect_option()]) -> {ok, #sslsocket{}} |
{error, reason()}.
-spec connect(host() | port(), [connect_option()] | inet:port_number(),
diff --git a/lib/ssl/src/ssl_app.erl b/lib/ssl/src/ssl_app.erl
index 62e8765d4a..d1bd113b0d 100644
--- a/lib/ssl/src/ssl_app.erl
+++ b/lib/ssl/src/ssl_app.erl
@@ -29,9 +29,26 @@
-export([start/2, stop/1]).
start(_Type, _StartArgs) ->
+ start_logger(),
ssl_sup:start_link().
stop(_State) ->
+ stop_logger(),
ok.
+%%
+%% Description: Start SSL logger
+start_logger() ->
+ Config = #{level => info,
+ filter_default => stop,
+ formatter => {logger_ssl_formatter, #{}}},
+ Filter = {fun logger_filters:domain/2,{log,starts_with,[beam,erlang,otp,ssl]}},
+ logger:add_handler(ssl_handler, logger_std_h, Config),
+ logger:add_handler_filter(ssl_handler, filter_non_ssl, Filter).
+
+%%
+%% Description: Stop SSL logger
+stop_logger() ->
+ logger:remove_handler(ssl_handler).
+