Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang
erlang
4132-megaco-Types-and-spec-for-megaco-enable_tr...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 4132-megaco-Types-and-spec-for-megaco-enable_trace-2.patch of Package erlang
From 999a21617ad16a2ccb592aeef32badd16c92c944 Mon Sep 17 00:00:00 2001 From: Micael Karlberg <bmk@erlang.org> Date: Fri, 22 Dec 2023 18:04:34 +0100 Subject: [PATCH 12/46] [megaco] Types and spec for megaco:enable_trace/2 OTP-18920 --- lib/megaco/doc/src/megaco.xml | 61 ++++++++++++++++++++++++----------- lib/megaco/src/app/megaco.erl | 19 ++++++++++- 2 files changed, 61 insertions(+), 19 deletions(-) diff --git a/lib/megaco/doc/src/megaco.xml b/lib/megaco/doc/src/megaco.xml index ca8d06506c..069a8071c4 100644 --- a/lib/megaco/doc/src/megaco.xml +++ b/lib/megaco/doc/src/megaco.xml @@ -254,6 +254,48 @@ --> </datatype> + <datatype> + <name name="trace_level"/> + <desc> + <p> + How much trace events should be produced. + <c><![CDATA[min]]></c> (=<c><![CDATA[0]]></c>) means no trace + events are produced, which is the default. + </p> + </desc> + </datatype> + + <datatype> + <name name="trace_event"/> + <desc> + <p> + The trace event generated by dbg. + </p> + </desc> + </datatype> + + <datatype> + <name name="trace_data"/> + <desc> + <p> + The trace data passed to the trace handler fun (in the + second argument) and returned by same. + For instance this could be a file descriptor, that the + trace handler fun can use to print the event to a file. + </p> + </desc> + </datatype> + + <datatype> + <name name="trace_handler"/> + <desc> + <p> + The trace handler fun is used to "process" each trace event + (for instance print to file or to stdout after formating). + </p> + </desc> + </datatype> + </datatypes> <section> @@ -1705,15 +1747,7 @@ megaco_incr_timer() = #megaco_incr_timer{} <func> <name name="disconnect" arity="2" clause_i="1" since=""/> - <!-- <name since="">disconnect(ConnHandle, DiscoReason) -> ok | {error, ErrReason}</name> --> <fsummary>Tear down a "virtual" connection</fsummary> - <!-- - <type> - <v>ConnHandle = conn_handle()</v> - <v>DiscoReason = term()</v> - <v>ErrReason = term()</v> - </type> - --> <desc> <p>Tear down a "virtual" connection</p> <p>Causes the <c><![CDATA[UserMod:handle_disconnect/2]]></c> @@ -2255,17 +2289,8 @@ megaco_incr_timer() = #megaco_incr_timer{} </func> <func> - <name since="">enable_trace(Level, Destination) -> void()</name> + <name name="enable_trace" arity="2" clause_i="1" since=""/> <fsummary>Start megaco tracing</fsummary> - <type> - <v>Level = max | min | 0 <= integer() <= 100</v> - <v>Destination = File | Port | HandlerSpec | io</v> - <v>File = string()</v> - <v>Port = integer()</v> - <v>HandleSpec = {HandlerFun, Data}</v> - <v>HandleFun = fun() (two arguments)</v> - <v>Data = term()</v> - </type> <desc> <p>This function is used to start megaco tracing at a given <c><![CDATA[Level]]></c> and direct result to the given <c><![CDATA[Destination]]></c>.</p> diff --git a/lib/megaco/src/app/megaco.erl b/lib/megaco/src/app/megaco.erl index 7be0b3ec74..517f97e6cd 100644 --- a/lib/megaco/src/app/megaco.erl +++ b/lib/megaco/src/app/megaco.erl @@ -113,7 +113,9 @@ property_parm/0, property_group/0, property_groups/0, - sdp/0 + sdp/0, + + trace_level/0 ]). -type void() :: term(). @@ -179,6 +181,11 @@ -type property_groups() :: megaco_sdp:property_groups(). -type sdp() :: megaco_sdp:sdp(). +-type trace_level() :: min | max | 0..100. +-type trace_event() :: term(). +-type trace_data() :: term(). +-type trace_handler() :: fun((trace_event(), trace_data()) -> trace_data()). + -include("megaco_internal.hrl"). @@ -1059,6 +1066,16 @@ find_file([], File) -> %% Severity withing Limit) will be written to stdout using io:format. %% %%----------------------------------------------------------------- + +-spec enable_trace(Level, Destination) -> void() when + Level :: trace_level(), + Destination :: File | Port | HandlerSpec | io, + File :: string(), + Port :: integer(), + HandlerSpec :: {HandlerFun, InitialData}, + HandlerFun :: trace_handler(), + InitialData :: trace_data(). + enable_trace(Level, File) when is_list(File) -> case file:open(File, [write]) of {ok, Fd} -> -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor