Skip to content

Commit 5776db9

Browse files
committed
Add logger_metadata option to ICEAgent
1 parent 4ca0455 commit 5776db9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/ex_ice/ice_agent.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ defmodule ExICE.ICEAgent do
8787
* `on_data` - where to send data. Defaults to a process that spawns `ExICE`.
8888
* `on_new_candidate` - where to send new candidates. Defaults to a process that spawns `ExICE`.
8989
* `host_to_srflx_ip_mapper` - function called for each host candidate to derive a new "fabricated" srflx candidate from it.
90+
* `logger_metadata` - a keyword list of metadata to be attached to the Logger for all logs emitted by the ICEAgent process.
9091
This function takes host's ip as an argument and should return srflx's ip as a result or nil if for given host candidate
9192
there should be no srflx one.
9293
"""
@@ -107,7 +108,8 @@ defmodule ExICE.ICEAgent do
107108
on_connection_state_change: pid() | nil,
108109
on_data: pid() | nil,
109110
on_new_candidate: pid() | nil,
110-
host_to_srflx_ip_mapper: host_to_srflx_ip_mapper() | nil
111+
host_to_srflx_ip_mapper: host_to_srflx_ip_mapper() | nil,
112+
logger_metadata: Enumerable.t({atom(), term()})
111113
]
112114

113115
@doc """
@@ -321,6 +323,8 @@ defmodule ExICE.ICEAgent do
321323

322324
@impl true
323325
def init(opts) do
326+
if Keyword.has_key?(opts, :logger_metadata), do: Logger.metadata(opts[:logger_metadata])
327+
324328
ice_agent = ExICE.Priv.ICEAgent.new(opts)
325329
{:ok, %{ice_agent: ice_agent, pending_eoc: false, pending_remote_cands: MapSet.new()}}
326330
end

0 commit comments

Comments
 (0)