fixeria submitted this change.
s1ap_proxy: use Global-ENB-ID as logging prefix
Change-Id: Ib3584237e60274c0276e750728b2bb2950f376a4
---
M src/s1ap_proxy.erl
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl
index bf5f849..66d558d 100644
--- a/src/s1ap_proxy.erl
+++ b/src/s1ap_proxy.erl
@@ -171,6 +171,11 @@
%% private API
%% ------------------------------------------------------------------
+-spec set_logging_prefix(string()) -> ok.
+set_logging_prefix(Prefix) when is_list(Prefix) ->
+ logger:set_process_metadata(#{prefix => Prefix}).
+
+
-spec erab_uid(erab_id(), proxy_state()) -> erab_uid().
erab_uid(ERABId, #proxy_state{mme_ue_id = MmeUeId,
enb_ue_id = EnbUeId}) ->
@@ -228,6 +233,12 @@
parse_enb_id({'long-macroENB-ID', << ID:21 >>}) -> ID.
+-spec genb_id_str(proxy_state()) -> string().
+genb_id_str(#proxy_state{plmn_id = {MCC, MNC},
+ enb_id = ENBId}) ->
+ MCC ++ "-" ++ MNC ++ "-" ++ integer_to_list(ENBId).
+
+
%% Encode an S1AP PDU
-spec encode_pdu(s1ap_pdu()) -> {ok, binary()} |
{error, {asn1, tuple()}}.
@@ -586,12 +597,13 @@
#'Global-ENB-ID'{'pLMNidentity' = PLMNId,
'eNB-ID' = ENBId} = C, S0) ->
%% store PLMNId/ENBId
- %% TODO: use that as a context for logging
S1 = S0#proxy_state{plmn_id = parse_plmn_id(PLMNId),
enb_id = parse_enb_id(ENBId)},
?LOG_INFO("Global-ENB-ID: PLMN-ID=~p, eNB-ID=~p",
[S1#proxy_state.plmn_id,
S1#proxy_state.enb_id]),
+ %% use that as a context for logging
+ set_logging_prefix("eNB " ++ genb_id_str(S1)),
{{ok, C}, S1};
%% E-RAB SETUP REQUEST related IEs
To view, visit change 40384. To unsubscribe, or for help writing mail filters, visit settings.