diff options
author | Siri Hansen <[email protected]> | 2018-05-02 19:20:27 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2018-05-07 12:02:25 +0200 |
commit | 3cef0524e4332ebf547180ec0d0feafe0a559b5c (patch) | |
tree | 26d95510da97051b94e31435249a5d409673af53 /lib/kernel/src | |
parent | 336e7eed4e44fe9267234e4702db6fd613064dcd (diff) | |
download | otp-3cef0524e4332ebf547180ec0d0feafe0a559b5c.tar.gz otp-3cef0524e4332ebf547180ec0d0feafe0a559b5c.tar.bz2 otp-3cef0524e4332ebf547180ec0d0feafe0a559b5c.zip |
Add logger:update_process_metadata/1
Diffstat (limited to 'lib/kernel/src')
-rw-r--r-- | lib/kernel/src/logger.erl | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/kernel/src/logger.erl b/lib/kernel/src/logger.erl index 943ef8c2d1..5562764204 100644 --- a/lib/kernel/src/logger.erl +++ b/lib/kernel/src/logger.erl @@ -44,8 +44,8 @@ %% Misc -export([compare_levels/2]). --export([set_process_metadata/1, unset_process_metadata/0, - get_process_metadata/0]). +-export([set_process_metadata/1, update_process_metadata/1, + unset_process_metadata/0, get_process_metadata/0]). -export([i/0, i/1]). -export([setup_standard_handler/0, replace_simple_handler/3]). -export([limit_term/1, get_format_depth/0, get_max_size/0, get_utc_config/0]). @@ -390,6 +390,19 @@ set_process_metadata(Meta) when is_map(Meta) -> set_process_metadata(Meta) -> erlang:error(badarg,[Meta]). +-spec update_process_metadata(Meta) -> ok when + Meta :: metadata(). +update_process_metadata(Meta) when is_map(Meta) -> + case get_process_metadata() of + undefined -> + set_process_metadata(Meta); + Meta0 when is_map(Meta0) -> + set_process_metadata(maps:merge(Meta0,Meta)), + ok + end; +update_process_metadata(Meta) -> + erlang:error(badarg,[Meta]). + -spec get_process_metadata() -> Meta | undefined when Meta :: metadata(). get_process_metadata() -> |