From: Mike Stepanek (mstepane) Date: Mon, 14 Jun 2021 13:20:36 +0000 (+0000) Subject: Merge pull request #2940 in SNORT/snort3 from ~OSHUMEIK/snort3:trace_opts to master X-Git-Tag: 3.1.6.0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9bbf003ae2851acfb63a9eb3b87b659914fe0b35;p=thirdparty%2Fsnort3.git Merge pull request #2940 in SNORT/snort3 from ~OSHUMEIK/snort3:trace_opts to master Squashed commit of the following: commit 2369f1fe6526c58ac35aa51f394526bc26a7ea46 Author: Oleksii Shumeiko Date: Thu Jun 3 15:50:00 2021 +0300 trace: place trace options under the DEBUG_MSGS macro Excluding: * trace.modules.snort.inspector_manager * trace.modules.wizard Check that option index is not out-of-bounds. dev_notes.txt updated. commit 34e1b91e91cc7c973aa132bd60f4b9fc5a238d3f Author: Oleksii Shumeiko Date: Thu Jun 3 14:55:58 2021 +0300 iec104: delete trailing spaces --- diff --git a/src/actions/act_react.cc b/src/actions/act_react.cc index 1d042eaf4..4582062cc 100644 --- a/src/actions/act_react.cc +++ b/src/actions/act_react.cc @@ -245,8 +245,12 @@ public: const TraceOption* get_trace_options() const override { +#ifndef DEBUG_MSGS + return nullptr; +#else static const TraceOption react_trace_options(nullptr, 0, nullptr); return &react_trace_options; +#endif } std::string get_data(); diff --git a/src/codecs/codec_module.cc b/src/codecs/codec_module.cc index 2953bde08..16c6c6a9a 100644 --- a/src/codecs/codec_module.cc +++ b/src/codecs/codec_module.cc @@ -44,8 +44,12 @@ void CodecModule::set_trace(const Trace* trace) const const TraceOption* CodecModule::get_trace_options() const { +#ifndef DEBUG_MSGS + return nullptr; +#else static const TraceOption codec_trace_options(nullptr, 0, nullptr); return &codec_trace_options; +#endif } static const RuleMap general_decode_rules[] = diff --git a/src/detection/detection_module.cc b/src/detection/detection_module.cc index a9fe67244..169e2012a 100644 --- a/src/detection/detection_module.cc +++ b/src/detection/detection_module.cc @@ -38,6 +38,7 @@ using namespace snort; THREAD_LOCAL const Trace* detection_trace = nullptr; +#ifdef DEBUG_MSGS static const TraceOption detection_trace_options[] = { { "detect_engine", TRACE_DETECTION_ENGINE, "enable detection engine trace logging" }, @@ -48,9 +49,9 @@ static const TraceOption detection_trace_options[] = { "pkt_detect", TRACE_PKT_DETECTION, "enable packet detection trace logging" }, { "opt_tree", TRACE_OPTION_TREE, "enable tree option trace logging" }, { "tag", TRACE_TAG, "enable tag trace logging" }, - { nullptr, 0, nullptr } }; +#endif static const Parameter detection_params[] = { @@ -110,7 +111,13 @@ void DetectionModule::set_trace(const Trace* trace) const { detection_trace = trace; } const TraceOption* DetectionModule::get_trace_options() const -{ return detection_trace_options; } +{ +#ifndef DEBUG_MSGS + return nullptr; +#else + return detection_trace_options; +#endif +} bool DetectionModule::end(const char*, int, SnortConfig* sc) { diff --git a/src/latency/latency_module.cc b/src/latency/latency_module.cc index 09618468f..f4c61d632 100644 --- a/src/latency/latency_module.cc +++ b/src/latency/latency_module.cc @@ -179,8 +179,12 @@ void LatencyModule::set_trace(const Trace* trace) const const TraceOption* LatencyModule::get_trace_options() const { +#ifndef DEBUG_MSGS + return nullptr; +#else static const TraceOption latency_trace_options(nullptr, 0, nullptr); return &latency_trace_options; +#endif } bool LatencyModule::set(const char* fqn, Value& v, SnortConfig* sc) diff --git a/src/main/snort_module.cc b/src/main/snort_module.cc index a57dbe2cb..a013ac424 100644 --- a/src/main/snort_module.cc +++ b/src/main/snort_module.cc @@ -181,8 +181,10 @@ static const Command snort_cmds[] = static const TraceOption snort_trace_options[] = { - { "main", TRACE_MAIN, "enable main trace logging" }, { "inspector_manager", TRACE_INSPECTOR_MANAGER, "enable inspector manager trace logging" }, +#ifdef DEBUG_MSGS + { "main", TRACE_MAIN, "enable main trace logging" }, +#endif { nullptr, 0, nullptr } }; diff --git a/src/main/snort_module.h b/src/main/snort_module.h index 5f7ff99cc..6f99f0be8 100644 --- a/src/main/snort_module.h +++ b/src/main/snort_module.h @@ -38,8 +38,8 @@ snort::Module* get_snort_module(); enum { - TRACE_MAIN = 0, - TRACE_INSPECTOR_MANAGER + TRACE_INSPECTOR_MANAGER = 0, + TRACE_MAIN, }; #endif diff --git a/src/network_inspectors/appid/appid_module.cc b/src/network_inspectors/appid/appid_module.cc index 3198bfbfa..08886116a 100644 --- a/src/network_inspectors/appid/appid_module.cc +++ b/src/network_inspectors/appid/appid_module.cc @@ -442,8 +442,12 @@ void AppIdModule::set_trace(const Trace* trace) const const TraceOption* AppIdModule::get_trace_options() const { +#ifndef DEBUG_MSGS + return nullptr; +#else static const TraceOption appid_trace_options(nullptr, 0, nullptr); return &appid_trace_options; +#endif } ProfileStats* AppIdModule::get_profile() const diff --git a/src/network_inspectors/rna/rna_module.cc b/src/network_inspectors/rna/rna_module.cc index af0a77360..4847509f2 100644 --- a/src/network_inspectors/rna/rna_module.cc +++ b/src/network_inspectors/rna/rna_module.cc @@ -592,8 +592,12 @@ void RnaModule::set_trace(const Trace* trace) const const TraceOption* RnaModule::get_trace_options() const { +#ifndef DEBUG_MSGS + return nullptr; +#else static const TraceOption rna_trace_options(nullptr, 0, nullptr); return &rna_trace_options; +#endif } bool RnaModule::log_mac_cache(const char* outfile) diff --git a/src/service_inspectors/dce_rpc/dce_smb_module.cc b/src/service_inspectors/dce_rpc/dce_smb_module.cc index 33cc952ba..881050c2b 100644 --- a/src/service_inspectors/dce_rpc/dce_smb_module.cc +++ b/src/service_inspectors/dce_rpc/dce_smb_module.cc @@ -335,8 +335,12 @@ void Dce2SmbModule::set_trace(const Trace* trace) const const TraceOption* Dce2SmbModule::get_trace_options() const { +#ifndef DEBUG_MSGS + return nullptr; +#else static const TraceOption dce_smb_trace_options(nullptr, 0, nullptr); return &dce_smb_trace_options; +#endif } const RuleMap* Dce2SmbModule::get_rules() const diff --git a/src/service_inspectors/dce_rpc/dce_udp_module.cc b/src/service_inspectors/dce_rpc/dce_udp_module.cc index 757022118..2298f39af 100644 --- a/src/service_inspectors/dce_rpc/dce_udp_module.cc +++ b/src/service_inspectors/dce_rpc/dce_udp_module.cc @@ -93,8 +93,12 @@ void Dce2UdpModule::set_trace(const Trace* trace) const const TraceOption* Dce2UdpModule::get_trace_options() const { +#ifndef DEBUG_MSGS + return nullptr; +#else static const TraceOption dce_udp_trace_options(nullptr, 0, nullptr); return &dce_udp_trace_options; +#endif } const RuleMap* Dce2UdpModule::get_rules() const diff --git a/src/service_inspectors/gtp/gtp_module.cc b/src/service_inspectors/gtp/gtp_module.cc index 32f068206..076ed396a 100644 --- a/src/service_inspectors/gtp/gtp_module.cc +++ b/src/service_inspectors/gtp/gtp_module.cc @@ -133,8 +133,12 @@ void GtpInspectModule::set_trace(const Trace* trace) const const TraceOption* GtpInspectModule::get_trace_options() const { +#ifndef DEBUG_MSGS + return nullptr; +#else static const TraceOption gtp_inspect_trace_options(nullptr, 0, nullptr); return >p_inspect_trace_options; +#endif } bool GtpInspectModule::set(const char*, Value& v, SnortConfig*) diff --git a/src/service_inspectors/iec104/iec104_module.cc b/src/service_inspectors/iec104/iec104_module.cc index e549255f6..df1811a13 100644 --- a/src/service_inspectors/iec104/iec104_module.cc +++ b/src/service_inspectors/iec104/iec104_module.cc @@ -38,25 +38,27 @@ THREAD_LOCAL ProfileStats iec104_prof; THREAD_LOCAL const Trace* iec104_trace = nullptr; +#ifdef DEBUG_MSGS static const TraceOption iec104_trace_options[] = { { "identification", TRACE_IEC104_IDENTIFICATION, "enable IEC104 APDU identification trace logging" }, { nullptr, 0, nullptr } }; +#endif //------------------------------------------------------------------------- // stats //------------------------------------------------------------------------- -const PegInfo peg_names[] = -{ - { CountType::SUM, "sessions", "total sessions processed" }, - { CountType::SUM, "frames", "total IEC104 messages" }, - { CountType::NOW, "concurrent_sessions", "total concurrent IEC104 sessions" }, +const PegInfo peg_names[] = +{ + { CountType::SUM, "sessions", "total sessions processed" }, + { CountType::SUM, "frames", "total IEC104 messages" }, + { CountType::NOW, "concurrent_sessions", "total concurrent IEC104 sessions" }, { CountType::MAX, "max_concurrent_sessions", "maximum concurrent IEC104 sessions" }, - { CountType::END, nullptr, nullptr } + { CountType::END, nullptr, nullptr } }; const PegInfo* Iec104Module::get_pegs() const @@ -73,71 +75,77 @@ PegCount* Iec104Module::get_counts() const // rules //------------------------------------------------------------------------- -static const RuleMap Iec104_rules[] = -{ - { IEC104_BAD_LENGTH, IEC104_BAD_LENGTH_STR }, - { IEC104_BAD_START, IEC104_BAD_START_STR }, - { IEC104_RESERVED_ASDU_TYPE, IEC104_RESERVED_ASDU_TYPE_STR }, - { IEC104_APCIU_RESERVED_FIELD_IN_USE, IEC104_APCIU_RESERVED_FIELD_IN_USE_STR }, - { IEC104_APCIU_INVALID_MESSAGE_TYPE, IEC104_APCIU_INVALID_MESSAGE_TYPE_STR }, - { IEC104_APCIS_RESERVED_FIELD_IN_USE, IEC104_APCIS_RESERVED_FIELD_IN_USE_STR }, - { IEC104_APCII_NUM_ELEMENTS_SET_TO_ZERO, IEC104_APCII_NUM_ELEMENTS_SET_TO_ZERO_STR }, - { IEC104_APCII_INVALID_SQ_VALUE, IEC104_APCII_INVALID_SQ_VALUE_STR }, - { IEC104_APCII_INVALID_NUM_ELEMENTS_VALUE, IEC104_APCII_INVALID_NUM_ELEMENTS_VALUE_STR }, +static const RuleMap Iec104_rules[] = +{ + { IEC104_BAD_LENGTH, IEC104_BAD_LENGTH_STR }, + { IEC104_BAD_START, IEC104_BAD_START_STR }, + { IEC104_RESERVED_ASDU_TYPE, IEC104_RESERVED_ASDU_TYPE_STR }, + { IEC104_APCIU_RESERVED_FIELD_IN_USE, IEC104_APCIU_RESERVED_FIELD_IN_USE_STR }, + { IEC104_APCIU_INVALID_MESSAGE_TYPE, IEC104_APCIU_INVALID_MESSAGE_TYPE_STR }, + { IEC104_APCIS_RESERVED_FIELD_IN_USE, IEC104_APCIS_RESERVED_FIELD_IN_USE_STR }, + { IEC104_APCII_NUM_ELEMENTS_SET_TO_ZERO, IEC104_APCII_NUM_ELEMENTS_SET_TO_ZERO_STR }, + { IEC104_APCII_INVALID_SQ_VALUE, IEC104_APCII_INVALID_SQ_VALUE_STR }, + { IEC104_APCII_INVALID_NUM_ELEMENTS_VALUE, IEC104_APCII_INVALID_NUM_ELEMENTS_VALUE_STR }, { IEC104_RESERVED_COI, IEC104_RESERVED_COI_STR }, { IEC104_RESERVED_QOI, IEC104_RESERVED_QOI_STR }, - { IEC104_RESERVED_QCC, IEC104_RESERVED_QCC_STR }, - { IEC104_RESERVED_QPM_KPA, IEC104_RESERVED_QPM_KPA_STR }, - { IEC104_ABNORMAL_QPM_LPC, IEC104_ABNORMAL_QPM_LPC_STR }, - { IEC104_ABNORMAL_QPM_POP, IEC104_ABNORMAL_QPM_POP_STR }, - { IEC104_RESERVED_QPA, IEC104_RESERVED_QPA_STR }, - { IEC104_RESERVED_QOC, IEC104_RESERVED_QOC_STR }, - { IEC104_RESERVED_QRP, IEC104_RESERVED_QRP_STR }, - { IEC104_RESERVED_FRQ, IEC104_RESERVED_FRQ_STR }, - { IEC104_RESERVED_SRQ, IEC104_RESERVED_SRQ_STR }, - { IEC104_RESERVED_SCQ, IEC104_RESERVED_SCQ_STR }, - { IEC104_RESERVED_LSQ, IEC104_RESERVED_LSQ_STR }, - { IEC104_RESERVED_AFQ, IEC104_RESERVED_AFQ_STR }, - { IEC104_VSQ_ABNORMAL_SQ, IEC104_VSQ_ABNORMAL_SQ_STR }, - { IEC104_RESERVED_CAUSE_TX, IEC104_RESERVED_CAUSE_TX_STR }, - { IEC104_INVALID_CAUSE_TX, IEC104_INVALID_CAUSE_TX_STR }, - { IEC104_INVALID_COMMON_ADDRESS, IEC104_INVALID_COMMON_ADDRESS_STR }, - { IEC104_RESERVED_SIQ, IEC104_RESERVED_SIQ_STR }, - { IEC104_RESERVED_DIQ, IEC104_RESERVED_DIQ_STR }, - { IEC104_RESERVED_QDS, IEC104_RESERVED_QDS_STR }, - { IEC104_RESERVED_QDP, IEC104_RESERVED_QDP_STR }, - { IEC104_RESERVED_IEEE_STD_754_NAN, IEC104_RESERVED_IEEE_STD_754_NAN_STR }, - { IEC104_RESERVED_IEEE_STD_754_INFINITY, IEC104_RESERVED_IEEE_STD_754_INFINITY_STR }, - { IEC104_RESERVED_SEP, IEC104_RESERVED_SEP_STR }, - { IEC104_RESERVED_SPE, IEC104_RESERVED_SPE_STR }, - { IEC104_RESERVED_OCI, IEC104_RESERVED_OCI_STR }, + { IEC104_RESERVED_QCC, IEC104_RESERVED_QCC_STR }, + { IEC104_RESERVED_QPM_KPA, IEC104_RESERVED_QPM_KPA_STR }, + { IEC104_ABNORMAL_QPM_LPC, IEC104_ABNORMAL_QPM_LPC_STR }, + { IEC104_ABNORMAL_QPM_POP, IEC104_ABNORMAL_QPM_POP_STR }, + { IEC104_RESERVED_QPA, IEC104_RESERVED_QPA_STR }, + { IEC104_RESERVED_QOC, IEC104_RESERVED_QOC_STR }, + { IEC104_RESERVED_QRP, IEC104_RESERVED_QRP_STR }, + { IEC104_RESERVED_FRQ, IEC104_RESERVED_FRQ_STR }, + { IEC104_RESERVED_SRQ, IEC104_RESERVED_SRQ_STR }, + { IEC104_RESERVED_SCQ, IEC104_RESERVED_SCQ_STR }, + { IEC104_RESERVED_LSQ, IEC104_RESERVED_LSQ_STR }, + { IEC104_RESERVED_AFQ, IEC104_RESERVED_AFQ_STR }, + { IEC104_VSQ_ABNORMAL_SQ, IEC104_VSQ_ABNORMAL_SQ_STR }, + { IEC104_RESERVED_CAUSE_TX, IEC104_RESERVED_CAUSE_TX_STR }, + { IEC104_INVALID_CAUSE_TX, IEC104_INVALID_CAUSE_TX_STR }, + { IEC104_INVALID_COMMON_ADDRESS, IEC104_INVALID_COMMON_ADDRESS_STR }, + { IEC104_RESERVED_SIQ, IEC104_RESERVED_SIQ_STR }, + { IEC104_RESERVED_DIQ, IEC104_RESERVED_DIQ_STR }, + { IEC104_RESERVED_QDS, IEC104_RESERVED_QDS_STR }, + { IEC104_RESERVED_QDP, IEC104_RESERVED_QDP_STR }, + { IEC104_RESERVED_IEEE_STD_754_NAN, IEC104_RESERVED_IEEE_STD_754_NAN_STR }, + { IEC104_RESERVED_IEEE_STD_754_INFINITY, IEC104_RESERVED_IEEE_STD_754_INFINITY_STR }, + { IEC104_RESERVED_SEP, IEC104_RESERVED_SEP_STR }, + { IEC104_RESERVED_SPE, IEC104_RESERVED_SPE_STR }, + { IEC104_RESERVED_OCI, IEC104_RESERVED_OCI_STR }, { IEC104_INVALID_FBP, IEC104_INVALID_FBP_STR }, { IEC104_RESERVED_SCO, IEC104_RESERVED_SCO_STR }, { IEC104_INVALID_DCO, IEC104_INVALID_DCO_STR }, - { IEC104_RESERVED_RCO, IEC104_RESERVED_RCO_STR }, - { IEC104_INVALID_MS_IN_MINUTE, IEC104_INVALID_MS_IN_MINUTE_STR }, - { IEC104_INVALID_MINS_IN_HOUR, IEC104_INVALID_MINS_IN_HOUR_STR }, - { IEC104_RESERVED_MINS_IN_HOUR, IEC104_RESERVED_MINS_IN_HOUR_STR }, - { IEC104_INVALID_HOURS_IN_DAY, IEC104_INVALID_HOURS_IN_DAY_STR }, - { IEC104_RESERVED_HOURS_IN_DAY, IEC104_RESERVED_HOURS_IN_DAY_STR }, - { IEC104_INVALID_DAY_OF_MONTH, IEC104_INVALID_DAY_OF_MONTH_STR }, - { IEC104_INVALID_MONTH, IEC104_INVALID_MONTH_STR }, - { IEC104_RESERVED_MONTH, IEC104_RESERVED_MONTH_STR }, - { IEC104_INVALID_YEAR, IEC104_INVALID_YEAR_STR }, - { IEC104_NULL_LOS_VALUE, IEC104_NULL_LOS_VALUE_STR }, - { IEC104_INVALID_LOS_VALUE, IEC104_INVALID_LOS_VALUE_STR }, - { IEC104_RESERVED_YEAR, IEC104_RESERVED_YEAR_STR }, - { IEC104_RESERVED_SOF, IEC104_RESERVED_SOF_STR }, + { IEC104_RESERVED_RCO, IEC104_RESERVED_RCO_STR }, + { IEC104_INVALID_MS_IN_MINUTE, IEC104_INVALID_MS_IN_MINUTE_STR }, + { IEC104_INVALID_MINS_IN_HOUR, IEC104_INVALID_MINS_IN_HOUR_STR }, + { IEC104_RESERVED_MINS_IN_HOUR, IEC104_RESERVED_MINS_IN_HOUR_STR }, + { IEC104_INVALID_HOURS_IN_DAY, IEC104_INVALID_HOURS_IN_DAY_STR }, + { IEC104_RESERVED_HOURS_IN_DAY, IEC104_RESERVED_HOURS_IN_DAY_STR }, + { IEC104_INVALID_DAY_OF_MONTH, IEC104_INVALID_DAY_OF_MONTH_STR }, + { IEC104_INVALID_MONTH, IEC104_INVALID_MONTH_STR }, + { IEC104_RESERVED_MONTH, IEC104_RESERVED_MONTH_STR }, + { IEC104_INVALID_YEAR, IEC104_INVALID_YEAR_STR }, + { IEC104_NULL_LOS_VALUE, IEC104_NULL_LOS_VALUE_STR }, + { IEC104_INVALID_LOS_VALUE, IEC104_INVALID_LOS_VALUE_STR }, + { IEC104_RESERVED_YEAR, IEC104_RESERVED_YEAR_STR }, + { IEC104_RESERVED_SOF, IEC104_RESERVED_SOF_STR }, { IEC104_RESERVED_QOS, IEC104_RESERVED_QOS_STR }, - { 0, nullptr } + { 0, nullptr } }; void Iec104Module::set_trace(const Trace* trace) const { iec104_trace = trace; } const TraceOption* Iec104Module::get_trace_options() const -{ return iec104_trace_options; } +{ +#ifndef DEBUG_MSGS + return nullptr; +#else + return iec104_trace_options; +#endif +} const RuleMap* Iec104Module::get_rules() const { @@ -152,4 +160,3 @@ Iec104Module::Iec104Module() : Module(IEC104_NAME, IEC104_HELP) { } - diff --git a/src/stream/base/stream_module.cc b/src/stream/base/stream_module.cc index fc75c8a75..7895e8865 100644 --- a/src/stream/base/stream_module.cc +++ b/src/stream/base/stream_module.cc @@ -116,8 +116,12 @@ void StreamModule::set_trace(const Trace* trace) const const TraceOption* StreamModule::get_trace_options() const { +#ifndef DEBUG_MSGS + return nullptr; +#else static const TraceOption stream_trace_options(nullptr, 0, nullptr); return &stream_trace_options; +#endif } const PegInfo* StreamModule::get_pegs() const diff --git a/src/stream/ip/ip_module.cc b/src/stream/ip/ip_module.cc index 0549d3928..e01c25e08 100644 --- a/src/stream/ip/ip_module.cc +++ b/src/stream/ip/ip_module.cc @@ -140,8 +140,12 @@ void StreamIpModule::set_trace(const Trace* trace) const const TraceOption* StreamIpModule::get_trace_options() const { +#ifndef DEBUG_MSGS + return nullptr; +#else static const TraceOption stream_ip_trace_options(nullptr, 0, nullptr); return &stream_ip_trace_options; +#endif } const RuleMap* StreamIpModule::get_rules() const diff --git a/src/stream/tcp/tcp_module.cc b/src/stream/tcp/tcp_module.cc index 663686efa..2e2a5c11d 100644 --- a/src/stream/tcp/tcp_module.cc +++ b/src/stream/tcp/tcp_module.cc @@ -42,6 +42,7 @@ THREAD_LOCAL ProfileStats s5TcpPerfStats; THREAD_LOCAL const Trace* stream_tcp_trace = nullptr; +#ifdef DEBUG_MSGS static const TraceOption stream_tcp_trace_options[] = { { "segments", TRACE_SEGMENTS, "enable stream TCP segments trace logging" }, @@ -49,6 +50,7 @@ static const TraceOption stream_tcp_trace_options[] = { nullptr, 0, nullptr } }; +#endif const PegInfo tcp_pegs[] = { @@ -258,7 +260,13 @@ void StreamTcpModule::set_trace(const Trace* trace) const { stream_tcp_trace = trace; } const TraceOption* StreamTcpModule::get_trace_options() const -{ return stream_tcp_trace_options; } +{ +#ifndef DEBUG_MSGS + return nullptr; +#else + return stream_tcp_trace_options; +#endif +} const RuleMap* StreamTcpModule::get_rules() const { return stream_tcp_rules; } diff --git a/src/stream/user/user_module.cc b/src/stream/user/user_module.cc index a46f56157..e2b115fbe 100644 --- a/src/stream/user/user_module.cc +++ b/src/stream/user/user_module.cc @@ -66,8 +66,12 @@ void StreamUserModule::set_trace(const Trace* trace) const const TraceOption* StreamUserModule::get_trace_options() const { +#ifndef DEBUG_MSGS + return nullptr; +#else static const TraceOption stream_user_trace_options(nullptr, 0, nullptr); return &stream_user_trace_options; +#endif } bool StreamUserModule::set(const char*, Value& v, SnortConfig*) diff --git a/src/trace/dev_notes.txt b/src/trace/dev_notes.txt index 9e9b1c91d..cb3f272bf 100644 --- a/src/trace/dev_notes.txt +++ b/src/trace/dev_notes.txt @@ -67,6 +67,15 @@ This directory contains the trace logger framework. TraceApi placed into "trace_api.h/trace_api.cc" +* TraceOption + + Represents a targeted module's trace option. + The targeted module provides a list of its trace options, + which control the verbosity level of the module's trace messages. + Since the messages can be present in release-build and/or debug-build, + one should pay attention which option should be in the options list. + TraceOptionID indexes (for the module's trace options) must start from zero. + * Trace This class encapsulates trace verbosity functionality. diff --git a/src/trace/trace.cc b/src/trace/trace.cc index 974f92ed0..ae457958b 100644 --- a/src/trace/trace.cc +++ b/src/trace/trace.cc @@ -69,7 +69,9 @@ bool Trace::set(const std::string& trace_option_name, uint8_t trace_level) { if ( trace_option_name == option_name(index) ) { - option_levels[options[index].id] = trace_level; + auto option_id = options[index].id; + assert(option_id < size); + option_levels[option_id] = trace_level; return true; } }