-module(rumMsg). -include("eRum.hrl"). -export([new/4, new/5]). -export([message/1]). -export([timestamp/1]). -export([datetime/1]). -export([severity/1]). -export([severity_as_int/1]). -export([metadata/1]). -export([destinations/1]). -opaque rumMsg() :: #rumMsg{}. -export_type([rumMsg/0]). %% create with provided timestamp, handy for testing mostly -spec new(list(), erlang:timestamp(), rumLevel(), [tuple()], list()) -> rumMsg(). new(Msg, Timestamp, Severity, Metadata, Destinations) -> {Date, Time} = rumUtil:format_time(rumUtil:maybe_utc(rumUtil:localtime_ms(Timestamp))), #rumMsg{message = Msg, datetime = {Date, Time}, timestamp = Timestamp, severity = Severity, metadata = Metadata, destinations = Destinations}. -spec new(list(), rumLevel(), [tuple()], list()) -> rumMsg(). new(Msg, Severity, Metadata, Destinations) -> Now = os:timestamp(), new(Msg, Now, Severity, Metadata, Destinations). -spec message(rumMsg()) -> list(). message(Msg) -> Msg#rumMsg.message. -spec timestamp(rumMsg()) -> erlang:timestamp(). timestamp(Msg) -> Msg#rumMsg.timestamp. -spec datetime(rumMsg()) -> {string(), string()}. datetime(Msg) -> Msg#rumMsg.datetime. -spec severity(rumMsg()) -> rumLevel(). severity(Msg) -> Msg#rumMsg.severity. -spec severity_as_int(rumMsg()) -> rumLevelNum(). severity_as_int(Msg) -> rumUtil:levelToNum(Msg#rumMsg.severity). -spec metadata(rumMsg()) -> [tuple()]. metadata(Msg) -> Msg#rumMsg.metadata. -spec destinations(rumMsg()) -> list(). destinations(Msg) -> Msg#rumMsg.destinations.