Module ocs_log

This library module implements functions used in handling logging in the ocs application.

Copyright © 2016 - 2026 SigScale Global Inc.

References

Description

This library module implements functions used in handling logging in the ocs application.

Event logging in ocs uses disk_log wrap logs configured for file size, and number of files, using application environment variables (e.g. acct_log_size, acct_log_files). As the log items are chronologically ordered finding an event by start time is relatively efficient. The btree_search/2 function is used to perform a binary tree search across the files and a chunk head comparison to quickly find the file and chunk containing items with a given start time.

All log items have the common form: Functions reading log files SHALL assume the above format and SHOULD ignore items with unexpected tuple arity or element values.

Data Types

abmf_event()

abmf_event() = {Timestamp::ocs_log:timestamp(), N::ocs_log:unique(), Node::atom(), Type::topup | adjustment | delete | deduct | reserve | unreserve | transfer, Subscriber::binary(), Bucket::undefined | string(), Units::cents | seconds | octets | messages, Product::string(), Amount::integer(), AmountBefore::integer() | undefined, AmountAfter::integer() | undefined, Validity::undefined | pos_integer(), Channel::undefined | string(), Requestor::undefined | [{Id::string(), Role::string(), Name::string()}], RelatedParty::undefined | [{Id::string(), Role::string(), Name::string()}], PaymentMeans::undefined | string(), Action::undefined | string(), Status::undefined | term()}

acct_event()

acct_event() = {Timestamp::ocs_log:timestamp(), N::ocs_log:unique(), Protocol::ocs_log:protocol(), Node::atom(), Server::ocs_log:server(), Type::ocs_log:acct_type(), RequestAttributes::ocs_log:acct_request(), ResponseAttributes::ocs_log:acct_response(), Rated::[#rated{bucket_value = non_neg_integer() | undefined | '_', bucket_type = cents | octets | seconds | messages | undefined | '_', currency = string() | undefined | '_', is_billed = boolean() | '_', is_tax_exempt = boolean() | undefined | '_', tariff_type = atom() | undefined | '_', product = term() | undefined | '_', price_name = string() | undefined | '_', price_type = tariff | usage | event | undefined | '_', description = string() | undefined | '_', tax_excluded_amount = non_neg_integer() | undefined | '_', tax_included_amount = non_neg_integer() | undefined | '_', tax_rate = integer() | undefined | '_', usage_rating_tag = usage | included | non_included | undefined | '_'}]}

acct_rated()

acct_rated() = [#rated{bucket_value = non_neg_integer() | undefined | '_', bucket_type = cents | octets | seconds | messages | undefined | '_', currency = string() | undefined | '_', is_billed = boolean() | '_', is_tax_exempt = boolean() | undefined | '_', tariff_type = atom() | undefined | '_', product = term() | undefined | '_', price_name = string() | undefined | '_', price_type = tariff | usage | event | undefined | '_', description = string() | undefined | '_', tax_excluded_amount = non_neg_integer() | undefined | '_', tax_included_amount = non_neg_integer() | undefined | '_', tax_rate = integer() | undefined | '_', usage_rating_tag = usage | included | non_included | undefined | '_'}]

acct_request()

acct_request() = #'3gpp_ro_CCR'{} | #'3gpp_ro_RAR'{} | #'3gpp_gx_CCR'{} | #'3gpp_gx_RAR'{} | radius_attributes:attributes() | nrf_request()

acct_response()

acct_response() = #'3gpp_ro_CCA'{} | #'3gpp_ro_RAA'{} | #'3gpp_gx_CCA'{} | #'3gpp_gx_RAA'{} | radius_attributes:attributes() | nrf_response()

acct_type()

acct_type() = on | off | start | stop | update | interim | final | event

auth_event()

auth_event() = diameter_auth_event() | radius_auth_event()

auth_request()

auth_request() = auth_request_rad() | auth_request_dia()

auth_request_dia()

auth_request_dia() = #diameter_nas_app_AAR{} | #diameter_eap_app_DER{} | #'3gpp_sta_DER'{} | #'3gpp_swm_DER'{} | #'3gpp_sta_STR'{} | #'3gpp_swm_STR'{} | #'3gpp_s6b_STR'{} | #'3gpp_swx_RTR'{} | #'3gpp_s6b_AAR'{} | #'3gpp_s6a_AIR'{} | #'3gpp_s6a_ULR'{} | #'3gpp_s6a_PUR'{}

auth_request_rad()

auth_request_rad() = radius_attributes:attributes()

auth_response()

auth_response() = auth_response_rad() | auth_response_dia()

auth_response_dia()

auth_response_dia() = #diameter_nas_app_AAA{} | #diameter_eap_app_DEA{} | #'3gpp_sta_DEA'{} | #'3gpp_swm_DEA'{} | #'3gpp_sta_STA'{} | #'3gpp_swm_STA'{} | #'3gpp_s6b_STA'{} | #'3gpp_swx_RTA'{} | #'3gpp_s6b_AAA'{} | #'3gpp_s6a_AIA'{} | #'3gpp_s6a_ULA'{} | #'3gpp_s6a_PUA'{}

auth_response_rad()

auth_response_rad() = radius_attributes:attributes()

auth_type()

auth_type() = accept | reject | change

diameter_auth_event()

diameter_auth_event() = {Timestamp::ocs_log:timestamp(), N::ocs_log:unique(), Protocol::ocs_log:protocol(), Node::atom(), Server::ocs_log:server(), Client::ocs_log:server(), RequestAttributes::ocs_log:auth_request(), ResponseAttributes::ocs_log:auth_response()}

http_event()

http_event() = {Host::string(), User::string(), DateTime::string(), Method::string(), URI::string(), HttpStatus::string()}

nrf_request()

nrf_request() = map()

nrf_response()

nrf_response() = map()

protocol()

protocol() = radius | diameter | nrf

radius_auth_event()

radius_auth_event() = {Timestamp::ocs_log:timestamp(), N::ocs_log:unique(), Protocol::ocs_log:protocol(), Node::atom(), Server::ocs_log:server(), Client::ocs_log:server(), Type::ocs_log:auth_type(), RequestAttributes::ocs_log:auth_request(), ResponseAttributes::ocs_log:auth_response()}

server()

server() = {Address::inet:ip_address(), Port::non_neg_integer()} | undefined

timestamp()

timestamp() = pos_integer()

unique()

unique() = pos_integer()

Function Index

log_name/1Return log name from Var application environment variable.
acct_open/0Open an accounting event disk log.
acct_log/6Write an event to accounting log.
acct_close/0Close accounting disk log.
acct_query/5Query accounting log events with filters.
acct_query/6Query accounting log events with filters.
auth_open/0Open authorization event disk log.
auth_log/6Write a RADIUS event to authorization log.
auth_log/5Write a DIAMETER event to authorization log.
auth_query/6Query access log events with filters.
auth_query/7Query access log events with filters.
auth_close/0Close auth disk log.
http_query/8Query http log events with filters.
ipdr_log/4Log accounting records within range to new IPDR disk log.
ipdr_file/3Export internal IPDR disk log.
get_range/3Get all events in a log within a date/time range.
dump_file/2Write all logged events to a file.
http_file/2Write events logged by httpd to a file.
httpd_logname/1Find local name of httpd disk_log.
last/2Get the last MaxItems events in most recent item first order.
date/1Convert between Unix epoch timestamp and OTP date and time.
iso8601/1Convert between ISO 8601 and Unix epoch milliseconds.
uuid/0*
abmf_open/0Open balance activity event disk log.
abmf_log/15Write a balance activity log event.
abmf_query/8Query balance activity log events with filters.
auth_to_ecs/1Convert auth_event to ECS.
acct_to_ecs/1Convert auth_event to ECS.
btree_search/2Binary tree search of multi file wrap disk_log.
ipdr_codec/1*Convert ocs_acct log entry to IPDR log entry.
ipdr_ims/7*CODEC for IMS VOIP.
ipdr_ims_voip/6*
ipdr_wlan/6*CODEC for IPDR Wlan.
http_parse/1*
open_log/4*open disk log file.
write_log/2*write event into given log file.
close_log/1*close log files.
query_log/5*Filter events by Start and End.
acct_query/4Continue query of accounting log events.
auth_query/5Continue query of authentication log events.
abmf_query/6Continue query of balance activity log events.

Function Details

log_name/1

log_name(Var) -> Name

Return log name from Var application environment variable.

acct_open/0

acct_open() -> Result

Open an accounting event disk log.

acct_log/6

acct_log(Protocol, Server, Type, Request, Response, Rated) -> Result

Write an event to accounting log.

acct_close/0

acct_close() -> Result

Close accounting disk log.

acct_query/5

acct_query(Continuation, Start, End, Types, Matches) -> Result

Equivalent to acct_query(Continuation, Start, End, '_', Types, AttrsMatch).

Query accounting log events with filters.

acct_query/6

acct_query(Continuation, Start, End, Protocol, Types, Matches) -> Result

Query accounting log events with filters.

The first time called Continuation should have the value start.

Events before Start or after Stop, or which do not match the Protocol or one of the Types, are ignored.

Events which do not include Attribute in attributes are ignored. If Match is '_' any attribute value will match or {Operator, MatchValue} may be used for more complex queries.

All attribute filters must match or the event will be ignored.

Protocol, Types, or MatchSpec may be '_' which matches any value.

Returns a new Continuation and a list of matching accounting events. Successive calls use the new Continuation to read more events.

auth_open/0

auth_open() -> Result

Open authorization event disk log.

auth_log/6

auth_log(Protocol, Server, Client, Type, RequestAttributes, ResponseAttributes) -> Result

Write a RADIUS event to authorization log.

auth_log/5

auth_log(Protocol, Server, Client, Request, Response) -> Result

Write a DIAMETER event to authorization log.

auth_query/6

auth_query(Continuation, Start, End, Types, ReqAttrsMatch, RespAttrsMatch) -> Result

Equivalent to auth_query(Continuation, Start, End, '_', Types, ReqAttrsMatch, RespAttrsMatch).

Query access log events with filters.

auth_query/7

auth_query(Continuation, Start, End, Protocol, Types, ReqAttrsMatch, RespAttrsMatch) -> Result

Query access log events with filters.

The first time called Continuation should have the value start.

Events before Start or after Stop or which do not match Protocol or one of the Types are ignored.

Events which do not include Attribute in request or response attributes are ignored. If Match is '_' any attribute value will match or {Operator, MatchValue} may be used for more complex queries.

All attribute filters must match or the event will be ignored.

Protocol, Types, ReqAttrsMatch ResAttrsMatch may be '_' which matches any value.

Returns a new Continuation and a list of matching access events. Successive calls use the new Continuation to read more events.

auth_close/0

auth_close() -> Result

Close auth disk log.

http_query/8

http_query(Continuation, LogType, DateTime, Host, User, Method, URI, HTTPStatus) -> Result

Query http log events with filters

ipdr_log/4

ipdr_log(Type, File, Start, End) -> Result

Log accounting records within range to new IPDR disk log.

Creates a new disk_log:log(), or overwrites an existing, with filename File. The log starts with a #ipdrDocWLAN{} | #ipdrDocVoIP{} header, is followed by #ipdr_wlan{} | #ipdr_voip{} records, and ends with a #ipdrDocEnd{} trailer.

The ocs_acct log is searched for events created between Start and End which may be given as {{Year, Month, Day}, {Hour, Minute, Second}} or the native erlang:system_time(millisecond).

ipdr_file/3

ipdr_file(Type, LogFile, Format) -> Result

Export internal IPDR disk log.

Creates a file named LogFile.Format with the details from the disk_log:log() file LogFile created previously with ipdr_log/3.

get_range/3

get_range(Log, Start, End) -> Result

Get all events in a log within a date/time range.

dump_file/2

dump_file(Log, FileName) -> Result

Write all logged events to a file.

http_file/2

http_file(Log, FileName) -> Result

Write events logged by httpd to a file.

httpd_logname/1

httpd_logname(LogType) -> disk_log:log()

Find local name of httpd disk_log.

last/2

last(Log, MaxItems) -> Result

Get the last MaxItems events in most recent item first order.

date/1

date(DateTime) -> Result

Convert between Unix epoch timestamp and OTP date and time.

iso8601/1

iso8601(DateTime) -> DateTime

Convert between ISO 8601 and Unix epoch milliseconds. Parsing is not strict to allow prefix matching.

uuid/0 *

uuid() -> any()

abmf_open/0

abmf_open() -> Result

Open balance activity event disk log.

abmf_log/15

abmf_log(Type, ServiceId, Bucket, Units, Product, Amount, AmountBefore, AmountAfter, Validity, Channel, Requestor, RelatedParty, PaymentMeans, Action, Status) -> Result

Write a balance activity log event.

abmf_query/8

abmf_query(Continuation, Start, End, Type, Subscriber, Bucket, Units, Product) -> Result

Query balance activity log events with filters.

auth_to_ecs/1

auth_to_ecs(Event) -> ECS

Convert auth_event to ECS.

acct_to_ecs/1

acct_to_ecs(Event) -> ECS

Convert auth_event to ECS.

btree_search/2

btree_search(Log, Start) -> Result

Binary tree search of multi file wrap disk_log.

ipdr_codec/1 *

ipdr_codec(Event) -> IPDRs

Convert ocs_acct log entry to IPDR log entry.

ipdr_ims/7 *

ipdr_ims(ServiceType, Protocol, TimeStamp, ReqType, Req, Res, Rated) -> IPDR

CODEC for IMS VOIP

To do

ipdr_ims_voip/6 *

ipdr_ims_voip(Protocol, TimeStamp, ReqType, Req, Res, Rated) -> IPDR

ipdr_wlan/6 *

ipdr_wlan(Protocol, TimeStamp, ReqType, Req, Res, Rated) -> IPDRWlan

CODEC for IPDR Wlan

http_parse/1 *

http_parse(Event) -> any()

open_log/4 *

open_log(Directory, Log, LogSize, LogFiles) -> Result

open disk log file

write_log/2 *

write_log(Log, Event) -> Result

write event into given log file

close_log/1 *

close_log(Log) -> Result

close log files

query_log/5 *

query_log(Continuation, Start, End, Log, MFA) -> Result

Filter events by Start and End.

acct_query/4

acct_query(Continuation, Protocol, Types, Matches) -> Result

Continue query of accounting log events.

auth_query/5

auth_query(Continuation, Protocol, Types, ReqAttrsMatch, RespAttrsMatch) -> Result

Continue query of authentication log events.

abmf_query/6

abmf_query(Continuation, Type, Subscriber, Bucket, Units, Product) -> Result

Continue query of balance activity log events.


Generated by EDoc