Add a new program option to control how ASN1 messages get printed into the enb JSON report file.

master
faluco 3 years ago committed by faluco
parent df6ae7b0e0
commit d168536bc4

@ -81,12 +81,15 @@ class event_logger
event_logger() = default;
public:
/// ASN1 output printing format.
enum class asn1_output_format { text, octets };
/// Returns the instance of the event logger.
static event_logger_interface& get();
/// Uses the specified log channel for event logging.
/// NOTE: This method is not thread safe.
static void configure(srslog::log_channel& c);
static void configure(srslog::log_channel& c, asn1_output_format asn1_format);
private:
static std::unique_ptr<event_logger_interface> pimpl;

@ -76,7 +76,6 @@ DECLARE_METRIC("rnti", metric_rnti, uint16_t, "");
/// ASN1 message metrics.
DECLARE_METRIC("asn1_length", metric_asn1_length, uint32_t, "");
DECLARE_METRIC("asn1_message", metric_asn1_message, std::string, "");
DECLARE_METRIC("asn1_message_txt", metric_asn1_message_txt, std::string, ""); //: TODO:
/// Context for sector start/stop.
DECLARE_METRIC("pci", metric_pci, uint32_t, "");
@ -94,7 +93,6 @@ DECLARE_METRIC_SET("event_data",
metric_rnti,
metric_asn1_length,
metric_asn1_message,
metric_asn1_message_txt,
metric_asn1_type,
metric_additional);
using rrc_event_t = srslog::
@ -158,7 +156,9 @@ using rlf_detected_t = srslog::build_context_type<metric_type_tag,
class logging_event_logger : public event_logger_interface
{
public:
explicit logging_event_logger(srslog::log_channel& c) : event_channel(c) {}
logging_event_logger(srslog::log_channel& c, event_logger::asn1_output_format asn1_format) :
event_channel(c), asn1_format(asn1_format)
{}
void log_rrc_event(uint32_t enb_cc_idx,
const std::string& asn1_oct_str,
@ -169,14 +169,15 @@ public:
{
rrc_event_t ctx("");
const std::string& asn1 = (asn1_format == event_logger::asn1_output_format::octets) ? asn1_oct_str : asn1_txt_str;
ctx.write<metric_type_tag>("event");
ctx.write<metric_timestamp_tag>(get_time_stamp());
ctx.write<metric_sector_id>(enb_cc_idx);
ctx.write<metric_event_name>("rrc_log");
ctx.get<mset_rrc_event>().write<metric_rnti>(rnti);
ctx.get<mset_rrc_event>().write<metric_asn1_length>(asn1_oct_str.size());
ctx.get<mset_rrc_event>().write<metric_asn1_message>(asn1_oct_str);
ctx.get<mset_rrc_event>().write<metric_asn1_message_txt>(asn1_txt_str);
ctx.get<mset_rrc_event>().write<metric_asn1_length>(asn1.size());
ctx.get<mset_rrc_event>().write<metric_asn1_message>(asn1);
ctx.get<mset_rrc_event>().write<metric_asn1_type>(type);
ctx.get<mset_rrc_event>().write<metric_additional>(additional_info);
event_channel(ctx);
@ -245,12 +246,14 @@ public:
{
meas_report_event_t ctx("");
const std::string& asn1 = (asn1_format == event_logger::asn1_output_format::octets) ? asn1_oct_str : asn1_txt_str;
ctx.write<metric_type_tag>("event");
ctx.write<metric_timestamp_tag>(get_time_stamp());
ctx.write<metric_sector_id>(enb_cc_idx);
ctx.write<metric_event_name>("measurement_report");
ctx.get<mset_meas_report_event>().write<metric_asn1_length>(asn1_oct_str.size());
ctx.get<mset_meas_report_event>().write<metric_asn1_message>(asn1_oct_str);
ctx.get<mset_meas_report_event>().write<metric_asn1_length>(asn1.size());
ctx.get<mset_meas_report_event>().write<metric_asn1_message>(asn1);
ctx.get<mset_meas_report_event>().write<metric_rnti>(rnti);
event_channel(ctx);
}
@ -262,12 +265,14 @@ public:
{
rlf_report_event_t ctx("");
const std::string& asn1 = (asn1_format == event_logger::asn1_output_format::octets) ? asn1_oct_str : asn1_txt_str;
ctx.write<metric_type_tag>("event");
ctx.write<metric_timestamp_tag>(get_time_stamp());
ctx.write<metric_sector_id>(enb_cc_idx);
ctx.write<metric_event_name>("rlf_report");
ctx.get<mset_rlf_report_event>().write<metric_asn1_length>(asn1_oct_str.size());
ctx.get<mset_rlf_report_event>().write<metric_asn1_message>(asn1_oct_str);
ctx.get<mset_rlf_report_event>().write<metric_asn1_length>(asn1.size());
ctx.get<mset_rlf_report_event>().write<metric_asn1_message>(asn1);
ctx.get<mset_rlf_report_event>().write<metric_rnti>(rnti);
event_channel(ctx);
}
@ -318,7 +323,8 @@ public:
}
private:
srslog::log_channel& event_channel;
srslog::log_channel& event_channel;
event_logger::asn1_output_format asn1_format;
};
} // namespace
@ -330,7 +336,7 @@ event_logger_interface& event_logger::get()
return *pimpl;
}
void event_logger::configure(srslog::log_channel& c)
void event_logger::configure(srslog::log_channel& c, asn1_output_format asn1_format)
{
pimpl = std::unique_ptr<logging_event_logger>(new logging_event_logger(c));
pimpl = std::unique_ptr<logging_event_logger>(new logging_event_logger(c, asn1_format));
}

@ -325,7 +325,8 @@ enable = false
# metrics_csv_filename: File path to use for CSV metrics.
# report_json_enable: Write eNB report to JSON file (default disabled)
# report_json_filename: Report JSON filename (default /tmp/enb_report.json)
# alarms_log_enable: Enable Alarms logging (default diabled)
# report_json_asn1_oct: Prints ASN1 messages encoded as an octet string instead of plain text in the JSON report file
# alarms_log_enable: Enable Alarms logging (default disabled)
# alarms_filename: Alarms logging filename (default /tmp/alarms.log)
# tracing_enable: Write source code tracing information to a file.
# tracing_filename: File path to use for tracing information.
@ -357,6 +358,7 @@ enable = false
#metrics_csv_filename = /tmp/enb_metrics.csv
#report_json_enable = true
#report_json_filename = /tmp/enb_report.json
#report_json_asn1_oct = false
#alarms_log_enable = true
#alarms_filename = /tmp/enb_alarms.log
#tracing_enable = true

@ -85,6 +85,7 @@ struct general_args_t {
std::string metrics_csv_filename;
bool report_json_enable;
std::string report_json_filename;
bool report_json_asn1_oct;
bool alarms_log_enable;
std::string alarms_filename;
bool print_buffer_state;

@ -222,6 +222,7 @@ void parse_args(all_args_t* args, int argc, char* argv[])
("expert.lte_sample_rates", bpo::value<bool>(&use_standard_lte_rates)->default_value(false), "Whether to use default LTE sample rates instead of shorter variants.")
("expert.report_json_enable", bpo::value<bool>(&args->general.report_json_enable)->default_value(false), "Write eNB report to JSON file (default disabled)")
("expert.report_json_filename", bpo::value<string>(&args->general.report_json_filename)->default_value("/tmp/enb_report.json"), "Report JSON filename (default /tmp/enb_report.json)")
("expert.report_json_asn1_oct", bpo::value<bool>(&args->general.report_json_asn1_oct)->default_value(false), "Prints ASN1 messages encoded as an octet string instead of plain text in the JSON report file")
("expert.alarms_log_enable", bpo::value<bool>(&args->general.alarms_log_enable)->default_value(false), "Enable Alarms logging (default diabled)")
("expert.alarms_filename", bpo::value<string>(&args->general.alarms_filename)->default_value("/tmp/enb_alarms.log"), "Alarms logging filename (default /tmp/alarms.log)")
("expert.tracing_enable", bpo::value<bool>(&args->general.tracing_enable)->default_value(false), "Events tracing")
@ -578,7 +579,10 @@ int main(int argc, char* argv[])
// Configure the event logger just before starting the eNB class.
if (args.general.report_json_enable) {
event_logger::configure(json_channel);
event_logger::asn1_output_format format = (args.general.report_json_asn1_oct)
? event_logger::asn1_output_format::octets
: event_logger::asn1_output_format::text;
event_logger::configure(json_channel, format);
}
if (mlockall((uint32_t)MCL_CURRENT | (uint32_t)MCL_FUTURE) == -1) {

Loading…
Cancel
Save