diff --git a/src/groups/mqb/mqbcfg/mqbcfg.xsd b/src/groups/mqb/mqbcfg/mqbcfg.xsd index aa38a39c9d..2e3524dddf 100644 --- a/src/groups/mqb/mqbcfg/mqbcfg.xsd +++ b/src/groups/mqb/mqbcfg/mqbcfg.xsd @@ -38,6 +38,14 @@ + + + + + + + + @@ -51,6 +59,7 @@ + diff --git a/src/groups/mqb/mqbcfg/mqbcfg_messages.cpp b/src/groups/mqb/mqbcfg/mqbcfg_messages.cpp index 61585754c6..a86df18e3d 100644 --- a/src/groups/mqb/mqbcfg/mqbcfg_messages.cpp +++ b/src/groups/mqb/mqbcfg/mqbcfg_messages.cpp @@ -853,6 +853,155 @@ Heartbeat::print(bsl::ostream& stream, int level, int spacesPerLevel) const return stream; } +// ------------------- +// class LogDumpConfig +// ------------------- + +// CONSTANTS + +const char LogDumpConfig::CLASS_NAME[] = "LogDumpConfig"; + +const int LogDumpConfig::DEFAULT_INITIALIZER_RECORD_BUFFER_SIZE = 32768; + +const char LogDumpConfig::DEFAULT_INITIALIZER_RECORDING_LEVEL[] = "OFF"; + +const char LogDumpConfig::DEFAULT_INITIALIZER_TRIGGER_LEVEL[] = "OFF"; + +const bdlat_AttributeInfo LogDumpConfig::ATTRIBUTE_INFO_ARRAY[] = { + {ATTRIBUTE_ID_RECORD_BUFFER_SIZE, + "recordBufferSize", + sizeof("recordBufferSize") - 1, + "", + bdlat_FormattingMode::e_DEC}, + {ATTRIBUTE_ID_RECORDING_LEVEL, + "recordingLevel", + sizeof("recordingLevel") - 1, + "", + bdlat_FormattingMode::e_TEXT}, + {ATTRIBUTE_ID_TRIGGER_LEVEL, + "triggerLevel", + sizeof("triggerLevel") - 1, + "", + bdlat_FormattingMode::e_TEXT}}; + +// CLASS METHODS + +const bdlat_AttributeInfo* LogDumpConfig::lookupAttributeInfo(const char* name, + int nameLength) +{ + for (int i = 0; i < 3; ++i) { + const bdlat_AttributeInfo& attributeInfo = + LogDumpConfig::ATTRIBUTE_INFO_ARRAY[i]; + + if (nameLength == attributeInfo.d_nameLength && + 0 == bsl::memcmp(attributeInfo.d_name_p, name, nameLength)) { + return &attributeInfo; + } + } + + return 0; +} + +const bdlat_AttributeInfo* LogDumpConfig::lookupAttributeInfo(int id) +{ + switch (id) { + case ATTRIBUTE_ID_RECORD_BUFFER_SIZE: + return &ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RECORD_BUFFER_SIZE]; + case ATTRIBUTE_ID_RECORDING_LEVEL: + return &ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RECORDING_LEVEL]; + case ATTRIBUTE_ID_TRIGGER_LEVEL: + return &ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_TRIGGER_LEVEL]; + default: return 0; + } +} + +// CREATORS + +LogDumpConfig::LogDumpConfig(bslma::Allocator* basicAllocator) +: d_recordingLevel(DEFAULT_INITIALIZER_RECORDING_LEVEL, basicAllocator) +, d_triggerLevel(DEFAULT_INITIALIZER_TRIGGER_LEVEL, basicAllocator) +, d_recordBufferSize(DEFAULT_INITIALIZER_RECORD_BUFFER_SIZE) +{ +} + +LogDumpConfig::LogDumpConfig(const LogDumpConfig& original, + bslma::Allocator* basicAllocator) +: d_recordingLevel(original.d_recordingLevel, basicAllocator) +, d_triggerLevel(original.d_triggerLevel, basicAllocator) +, d_recordBufferSize(original.d_recordBufferSize) +{ +} + +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) +LogDumpConfig::LogDumpConfig(LogDumpConfig&& original) noexcept +: d_recordingLevel(bsl::move(original.d_recordingLevel)), + d_triggerLevel(bsl::move(original.d_triggerLevel)), + d_recordBufferSize(bsl::move(original.d_recordBufferSize)) +{ +} + +LogDumpConfig::LogDumpConfig(LogDumpConfig&& original, + bslma::Allocator* basicAllocator) +: d_recordingLevel(bsl::move(original.d_recordingLevel), basicAllocator) +, d_triggerLevel(bsl::move(original.d_triggerLevel), basicAllocator) +, d_recordBufferSize(bsl::move(original.d_recordBufferSize)) +{ +} +#endif + +LogDumpConfig::~LogDumpConfig() +{ +} + +// MANIPULATORS + +LogDumpConfig& LogDumpConfig::operator=(const LogDumpConfig& rhs) +{ + if (this != &rhs) { + d_recordBufferSize = rhs.d_recordBufferSize; + d_recordingLevel = rhs.d_recordingLevel; + d_triggerLevel = rhs.d_triggerLevel; + } + + return *this; +} + +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) +LogDumpConfig& LogDumpConfig::operator=(LogDumpConfig&& rhs) +{ + if (this != &rhs) { + d_recordBufferSize = bsl::move(rhs.d_recordBufferSize); + d_recordingLevel = bsl::move(rhs.d_recordingLevel); + d_triggerLevel = bsl::move(rhs.d_triggerLevel); + } + + return *this; +} +#endif + +void LogDumpConfig::reset() +{ + d_recordBufferSize = DEFAULT_INITIALIZER_RECORD_BUFFER_SIZE; + d_recordingLevel = DEFAULT_INITIALIZER_RECORDING_LEVEL; + d_triggerLevel = DEFAULT_INITIALIZER_TRIGGER_LEVEL; +} + +// ACCESSORS + +bsl::ostream& +LogDumpConfig::print(bsl::ostream& stream, int level, int spacesPerLevel) const +{ + bslim::Printer printer(&stream, level, spacesPerLevel); + printer.start(); + printer.printAttribute("recordBufferSize", this->recordBufferSize()); + printer.printAttribute("recordingLevel", this->recordingLevel()); + printer.printAttribute("triggerLevel", this->triggerLevel()); + printer.end(); + return stream; +} + // ------------------------------- // class MasterAssignmentAlgorithm // ------------------------------- @@ -3027,6 +3176,11 @@ const bdlat_AttributeInfo LogController::ATTRIBUTE_INFO_ARRAY[] = { "syslog", sizeof("syslog") - 1, "", + bdlat_FormattingMode::e_DEFAULT}, + {ATTRIBUTE_ID_LOG_DUMP, + "logDump", + sizeof("logDump") - 1, + "", bdlat_FormattingMode::e_DEFAULT}}; // CLASS METHODS @@ -3034,7 +3188,7 @@ const bdlat_AttributeInfo LogController::ATTRIBUTE_INFO_ARRAY[] = { const bdlat_AttributeInfo* LogController::lookupAttributeInfo(const char* name, int nameLength) { - for (int i = 0; i < 10; ++i) { + for (int i = 0; i < 11; ++i) { const bdlat_AttributeInfo& attributeInfo = LogController::ATTRIBUTE_INFO_ARRAY[i]; @@ -3072,6 +3226,8 @@ const bdlat_AttributeInfo* LogController::lookupAttributeInfo(int id) return &ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_CATEGORIES]; case ATTRIBUTE_ID_SYSLOG: return &ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SYSLOG]; + case ATTRIBUTE_ID_LOG_DUMP: + return &ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_LOG_DUMP]; default: return 0; } } @@ -3088,6 +3244,7 @@ LogController::LogController(bslma::Allocator* basicAllocator) basicAllocator) , d_consoleSeverityThreshold(basicAllocator) , d_syslog(basicAllocator) +, d_logDump(basicAllocator) , d_fileMaxAgeDays() , d_rotationBytes() { @@ -3105,6 +3262,7 @@ LogController::LogController(const LogController& original, , d_consoleSeverityThreshold(original.d_consoleSeverityThreshold, basicAllocator) , d_syslog(original.d_syslog, basicAllocator) +, d_logDump(original.d_logDump, basicAllocator) , d_fileMaxAgeDays(original.d_fileMaxAgeDays) , d_rotationBytes(original.d_rotationBytes) { @@ -3121,6 +3279,7 @@ LogController::LogController(LogController&& original) noexcept d_bslsLogSeverityThreshold(bsl::move(original.d_bslsLogSeverityThreshold)), d_consoleSeverityThreshold(bsl::move(original.d_consoleSeverityThreshold)), d_syslog(bsl::move(original.d_syslog)), + d_logDump(bsl::move(original.d_logDump)), d_fileMaxAgeDays(bsl::move(original.d_fileMaxAgeDays)), d_rotationBytes(bsl::move(original.d_rotationBytes)) { @@ -3138,6 +3297,7 @@ LogController::LogController(LogController&& original, , d_consoleSeverityThreshold(bsl::move(original.d_consoleSeverityThreshold), basicAllocator) , d_syslog(bsl::move(original.d_syslog), basicAllocator) +, d_logDump(bsl::move(original.d_logDump), basicAllocator) , d_fileMaxAgeDays(bsl::move(original.d_fileMaxAgeDays)) , d_rotationBytes(bsl::move(original.d_rotationBytes)) { @@ -3163,6 +3323,7 @@ LogController& LogController::operator=(const LogController& rhs) d_consoleSeverityThreshold = rhs.d_consoleSeverityThreshold; d_categories = rhs.d_categories; d_syslog = rhs.d_syslog; + d_logDump = rhs.d_logDump; } return *this; @@ -3183,6 +3344,7 @@ LogController& LogController::operator=(LogController&& rhs) d_consoleSeverityThreshold = bsl::move(rhs.d_consoleSeverityThreshold); d_categories = bsl::move(rhs.d_categories); d_syslog = bsl::move(rhs.d_syslog); + d_logDump = bsl::move(rhs.d_logDump); } return *this; @@ -3202,6 +3364,7 @@ void LogController::reset() bdlat_ValueTypeFunctions::reset(&d_consoleSeverityThreshold); bdlat_ValueTypeFunctions::reset(&d_categories); bdlat_ValueTypeFunctions::reset(&d_syslog); + bdlat_ValueTypeFunctions::reset(&d_logDump); } // ACCESSORS @@ -3223,6 +3386,7 @@ LogController::print(bsl::ostream& stream, int level, int spacesPerLevel) const this->consoleSeverityThreshold()); printer.printAttribute("categories", this->categories()); printer.printAttribute("syslog", this->syslog()); + printer.printAttribute("logDump", this->logDump()); printer.end(); return stream; } @@ -5823,7 +5987,7 @@ Configuration::print(bsl::ostream& stream, int level, int spacesPerLevel) const } // close package namespace } // close enterprise namespace -// GENERATED BY @BLP_BAS_CODEGEN_VERSION@ +// GENERATED BY BLP_BAS_CODEGEN_2024.09.20 // USING bas_codegen.pl -m msg --noAggregateConversion --noExternalization // --noIdent --package mqbcfg --msgComponent messages mqbcfg.xsd // ---------------------------------------------------------------------------- diff --git a/src/groups/mqb/mqbcfg/mqbcfg_messages.h b/src/groups/mqb/mqbcfg/mqbcfg_messages.h index 9875c6ab2d..d1ef2fc4e1 100644 --- a/src/groups/mqb/mqbcfg/mqbcfg_messages.h +++ b/src/groups/mqb/mqbcfg/mqbcfg_messages.h @@ -75,6 +75,9 @@ namespace mqbcfg { class Heartbeat; } namespace mqbcfg { +class LogDumpConfig; +} +namespace mqbcfg { class MessagePropertiesV2; } namespace mqbcfg { @@ -1656,6 +1659,249 @@ BDLAT_DECL_SEQUENCE_WITH_BITWISEMOVEABLE_TRAITS(mqbcfg::Heartbeat) namespace mqbcfg { +// =================== +// class LogDumpConfig +// =================== + +class LogDumpConfig { + // INSTANCE DATA + bsl::string d_recordingLevel; + bsl::string d_triggerLevel; + int d_recordBufferSize; + + // PRIVATE ACCESSORS + template + void hashAppendImpl(t_HASH_ALGORITHM& hashAlgorithm) const; + + public: + // TYPES + enum { + ATTRIBUTE_ID_RECORD_BUFFER_SIZE = 0, + ATTRIBUTE_ID_RECORDING_LEVEL = 1, + ATTRIBUTE_ID_TRIGGER_LEVEL = 2 + }; + + enum { NUM_ATTRIBUTES = 3 }; + + enum { + ATTRIBUTE_INDEX_RECORD_BUFFER_SIZE = 0, + ATTRIBUTE_INDEX_RECORDING_LEVEL = 1, + ATTRIBUTE_INDEX_TRIGGER_LEVEL = 2 + }; + + // CONSTANTS + static const char CLASS_NAME[]; + + static const int DEFAULT_INITIALIZER_RECORD_BUFFER_SIZE; + + static const char DEFAULT_INITIALIZER_RECORDING_LEVEL[]; + + static const char DEFAULT_INITIALIZER_TRIGGER_LEVEL[]; + + static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]; + + public: + // CLASS METHODS + static const bdlat_AttributeInfo* lookupAttributeInfo(int id); + // Return attribute information for the attribute indicated by the + // specified 'id' if the attribute exists, and 0 otherwise. + + static const bdlat_AttributeInfo* lookupAttributeInfo(const char* name, + int nameLength); + // Return attribute information for the attribute indicated by the + // specified 'name' of the specified 'nameLength' if the attribute + // exists, and 0 otherwise. + + // CREATORS + explicit LogDumpConfig(bslma::Allocator* basicAllocator = 0); + // Create an object of type 'LogDumpConfig' having the default value. + // Use the optionally specified 'basicAllocator' to supply memory. If + // 'basicAllocator' is 0, the currently installed default allocator is + // used. + + LogDumpConfig(const LogDumpConfig& original, + bslma::Allocator* basicAllocator = 0); + // Create an object of type 'LogDumpConfig' having the value of the + // specified 'original' object. Use the optionally specified + // 'basicAllocator' to supply memory. If 'basicAllocator' is 0, the + // currently installed default allocator is used. + +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) + LogDumpConfig(LogDumpConfig&& original) noexcept; + // Create an object of type 'LogDumpConfig' having the value of the + // specified 'original' object. After performing this action, the + // 'original' object will be left in a valid, but unspecified state. + + LogDumpConfig(LogDumpConfig&& original, bslma::Allocator* basicAllocator); + // Create an object of type 'LogDumpConfig' having the value of the + // specified 'original' object. After performing this action, the + // 'original' object will be left in a valid, but unspecified state. + // Use the optionally specified 'basicAllocator' to supply memory. If + // 'basicAllocator' is 0, the currently installed default allocator is + // used. +#endif + + ~LogDumpConfig(); + // Destroy this object. + + // MANIPULATORS + LogDumpConfig& operator=(const LogDumpConfig& rhs); + // Assign to this object the value of the specified 'rhs' object. + +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) + LogDumpConfig& operator=(LogDumpConfig&& rhs); + // Assign to this object the value of the specified 'rhs' object. + // After performing this action, the 'rhs' object will be left in a + // valid, but unspecified state. +#endif + + void reset(); + // Reset this object to the default value (i.e., its value upon + // default construction). + + template + int manipulateAttributes(t_MANIPULATOR& manipulator); + // Invoke the specified 'manipulator' sequentially on the address of + // each (modifiable) attribute of this object, supplying 'manipulator' + // with the corresponding attribute information structure until such + // invocation returns a non-zero value. Return the value from the + // last invocation of 'manipulator' (i.e., the invocation that + // terminated the sequence). + + template + int manipulateAttribute(t_MANIPULATOR& manipulator, int id); + // Invoke the specified 'manipulator' on the address of + // the (modifiable) attribute indicated by the specified 'id', + // supplying 'manipulator' with the corresponding attribute + // information structure. Return the value returned from the + // invocation of 'manipulator' if 'id' identifies an attribute of this + // class, and -1 otherwise. + + template + int manipulateAttribute(t_MANIPULATOR& manipulator, + const char* name, + int nameLength); + // Invoke the specified 'manipulator' on the address of + // the (modifiable) attribute indicated by the specified 'name' of the + // specified 'nameLength', supplying 'manipulator' with the + // corresponding attribute information structure. Return the value + // returned from the invocation of 'manipulator' if 'name' identifies + // an attribute of this class, and -1 otherwise. + + int& recordBufferSize(); + // Return a reference to the modifiable "RecordBufferSize" attribute of + // this object. + + bsl::string& recordingLevel(); + // Return a reference to the modifiable "RecordingLevel" attribute of + // this object. + + bsl::string& triggerLevel(); + // Return a reference to the modifiable "TriggerLevel" attribute of + // this object. + + // ACCESSORS + bsl::ostream& + print(bsl::ostream& stream, int level = 0, int spacesPerLevel = 4) const; + // Format this object to the specified output 'stream' at the + // optionally specified indentation 'level' and return a reference to + // the modifiable 'stream'. If 'level' is specified, optionally + // specify 'spacesPerLevel', the number of spaces per indentation level + // for this and all of its nested objects. Each line is indented by + // the absolute value of 'level * spacesPerLevel'. If 'level' is + // negative, suppress indentation of the first line. If + // 'spacesPerLevel' is negative, suppress line breaks and format the + // entire output on one line. If 'stream' is initially invalid, this + // operation has no effect. Note that a trailing newline is provided + // in multiline mode only. + + template + int accessAttributes(t_ACCESSOR& accessor) const; + // Invoke the specified 'accessor' sequentially on each + // (non-modifiable) attribute of this object, supplying 'accessor' + // with the corresponding attribute information structure until such + // invocation returns a non-zero value. Return the value from the + // last invocation of 'accessor' (i.e., the invocation that terminated + // the sequence). + + template + int accessAttribute(t_ACCESSOR& accessor, int id) const; + // Invoke the specified 'accessor' on the (non-modifiable) attribute + // of this object indicated by the specified 'id', supplying 'accessor' + // with the corresponding attribute information structure. Return the + // value returned from the invocation of 'accessor' if 'id' identifies + // an attribute of this class, and -1 otherwise. + + template + int accessAttribute(t_ACCESSOR& accessor, + const char* name, + int nameLength) const; + // Invoke the specified 'accessor' on the (non-modifiable) attribute + // of this object indicated by the specified 'name' of the specified + // 'nameLength', supplying 'accessor' with the corresponding attribute + // information structure. Return the value returned from the + // invocation of 'accessor' if 'name' identifies an attribute of this + // class, and -1 otherwise. + + int recordBufferSize() const; + // Return the value of the "RecordBufferSize" attribute of this object. + + const bsl::string& recordingLevel() const; + // Return a reference offering non-modifiable access to the + // "RecordingLevel" attribute of this object. + + const bsl::string& triggerLevel() const; + // Return a reference offering non-modifiable access to the + // "TriggerLevel" attribute of this object. + + // HIDDEN FRIENDS + friend bool operator==(const LogDumpConfig& lhs, const LogDumpConfig& rhs) + // Return 'true' if the specified 'lhs' and 'rhs' attribute objects + // have the same value, and 'false' otherwise. Two attribute objects + // have the same value if each respective attribute has the same value. + { + return lhs.recordBufferSize() == rhs.recordBufferSize() && + lhs.recordingLevel() == rhs.recordingLevel() && + lhs.triggerLevel() == rhs.triggerLevel(); + } + + friend bool operator!=(const LogDumpConfig& lhs, const LogDumpConfig& rhs) + // Returns '!(lhs == rhs)' + { + return !(lhs == rhs); + } + + friend bsl::ostream& operator<<(bsl::ostream& stream, + const LogDumpConfig& rhs) + // Format the specified 'rhs' to the specified output 'stream' and + // return a reference to the modifiable 'stream'. + { + return rhs.print(stream, 0, -1); + } + + template + friend void hashAppend(t_HASH_ALGORITHM& hashAlg, + const LogDumpConfig& object) + // Pass the specified 'object' to the specified 'hashAlg'. This + // function integrates with the 'bslh' modular hashing system and + // effectively provides a 'bsl::hash' specialization for + // 'LogDumpConfig'. + { + object.hashAppendImpl(hashAlg); + } +}; + +} // close package namespace + +// TRAITS + +BDLAT_DECL_SEQUENCE_WITH_ALLOCATOR_BITWISEMOVEABLE_TRAITS( + mqbcfg::LogDumpConfig) + +namespace mqbcfg { + // =============================== // class MasterAssignmentAlgorithm // =============================== @@ -4985,6 +5231,7 @@ class LogController { bsl::string d_bslsLogSeverityThreshold; bsl::string d_consoleSeverityThreshold; SyslogConfig d_syslog; + LogDumpConfig d_logDump; int d_fileMaxAgeDays; int d_rotationBytes; @@ -5006,10 +5253,11 @@ class LogController { ATTRIBUTE_ID_BSLS_LOG_SEVERITY_THRESHOLD = 6, ATTRIBUTE_ID_CONSOLE_SEVERITY_THRESHOLD = 7, ATTRIBUTE_ID_CATEGORIES = 8, - ATTRIBUTE_ID_SYSLOG = 9 + ATTRIBUTE_ID_SYSLOG = 9, + ATTRIBUTE_ID_LOG_DUMP = 10 }; - enum { NUM_ATTRIBUTES = 10 }; + enum { NUM_ATTRIBUTES = 11 }; enum { ATTRIBUTE_INDEX_FILE_NAME = 0, @@ -5021,7 +5269,8 @@ class LogController { ATTRIBUTE_INDEX_BSLS_LOG_SEVERITY_THRESHOLD = 6, ATTRIBUTE_INDEX_CONSOLE_SEVERITY_THRESHOLD = 7, ATTRIBUTE_INDEX_CATEGORIES = 8, - ATTRIBUTE_INDEX_SYSLOG = 9 + ATTRIBUTE_INDEX_SYSLOG = 9, + ATTRIBUTE_INDEX_LOG_DUMP = 10 }; // CONSTANTS @@ -5161,6 +5410,10 @@ class LogController { // Return a reference to the modifiable "Syslog" attribute of this // object. + LogDumpConfig& logDump(); + // Return a reference to the modifiable "LogDump" attribute of this + // object. + // ACCESSORS bsl::ostream& print(bsl::ostream& stream, int level = 0, int spacesPerLevel = 4) const; @@ -5242,6 +5495,10 @@ class LogController { // Return a reference offering non-modifiable access to the "Syslog" // attribute of this object. + const LogDumpConfig& logDump() const; + // Return a reference offering non-modifiable access to the "LogDump" + // attribute of this object. + // HIDDEN FRIENDS friend bool operator==(const LogController& lhs, const LogController& rhs) // Return 'true' if the specified 'lhs' and 'rhs' attribute objects @@ -10535,6 +10792,186 @@ inline int Heartbeat::clusterPeer() const return d_clusterPeer; } +// ------------------- +// class LogDumpConfig +// ------------------- + +// PRIVATE ACCESSORS +template +void LogDumpConfig::hashAppendImpl(t_HASH_ALGORITHM& hashAlgorithm) const +{ + using bslh::hashAppend; + hashAppend(hashAlgorithm, this->recordBufferSize()); + hashAppend(hashAlgorithm, this->recordingLevel()); + hashAppend(hashAlgorithm, this->triggerLevel()); +} + +// CLASS METHODS +// MANIPULATORS +template +int LogDumpConfig::manipulateAttributes(t_MANIPULATOR& manipulator) +{ + int ret; + + ret = manipulator( + &d_recordBufferSize, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RECORD_BUFFER_SIZE]); + if (ret) { + return ret; + } + + ret = manipulator(&d_recordingLevel, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RECORDING_LEVEL]); + if (ret) { + return ret; + } + + ret = manipulator(&d_triggerLevel, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_TRIGGER_LEVEL]); + if (ret) { + return ret; + } + + return 0; +} + +template +int LogDumpConfig::manipulateAttribute(t_MANIPULATOR& manipulator, int id) +{ + enum { NOT_FOUND = -1 }; + + switch (id) { + case ATTRIBUTE_ID_RECORD_BUFFER_SIZE: { + return manipulator( + &d_recordBufferSize, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RECORD_BUFFER_SIZE]); + } + case ATTRIBUTE_ID_RECORDING_LEVEL: { + return manipulator( + &d_recordingLevel, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RECORDING_LEVEL]); + } + case ATTRIBUTE_ID_TRIGGER_LEVEL: { + return manipulator( + &d_triggerLevel, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_TRIGGER_LEVEL]); + } + default: return NOT_FOUND; + } +} + +template +int LogDumpConfig::manipulateAttribute(t_MANIPULATOR& manipulator, + const char* name, + int nameLength) +{ + enum { NOT_FOUND = -1 }; + + const bdlat_AttributeInfo* attributeInfo = lookupAttributeInfo(name, + nameLength); + if (0 == attributeInfo) { + return NOT_FOUND; + } + + return manipulateAttribute(manipulator, attributeInfo->d_id); +} + +inline int& LogDumpConfig::recordBufferSize() +{ + return d_recordBufferSize; +} + +inline bsl::string& LogDumpConfig::recordingLevel() +{ + return d_recordingLevel; +} + +inline bsl::string& LogDumpConfig::triggerLevel() +{ + return d_triggerLevel; +} + +// ACCESSORS +template +int LogDumpConfig::accessAttributes(t_ACCESSOR& accessor) const +{ + int ret; + + ret = accessor(d_recordBufferSize, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RECORD_BUFFER_SIZE]); + if (ret) { + return ret; + } + + ret = accessor(d_recordingLevel, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RECORDING_LEVEL]); + if (ret) { + return ret; + } + + ret = accessor(d_triggerLevel, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_TRIGGER_LEVEL]); + if (ret) { + return ret; + } + + return 0; +} + +template +int LogDumpConfig::accessAttribute(t_ACCESSOR& accessor, int id) const +{ + enum { NOT_FOUND = -1 }; + + switch (id) { + case ATTRIBUTE_ID_RECORD_BUFFER_SIZE: { + return accessor( + d_recordBufferSize, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RECORD_BUFFER_SIZE]); + } + case ATTRIBUTE_ID_RECORDING_LEVEL: { + return accessor(d_recordingLevel, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_RECORDING_LEVEL]); + } + case ATTRIBUTE_ID_TRIGGER_LEVEL: { + return accessor(d_triggerLevel, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_TRIGGER_LEVEL]); + } + default: return NOT_FOUND; + } +} + +template +int LogDumpConfig::accessAttribute(t_ACCESSOR& accessor, + const char* name, + int nameLength) const +{ + enum { NOT_FOUND = -1 }; + + const bdlat_AttributeInfo* attributeInfo = lookupAttributeInfo(name, + nameLength); + if (0 == attributeInfo) { + return NOT_FOUND; + } + + return accessAttribute(accessor, attributeInfo->d_id); +} + +inline int LogDumpConfig::recordBufferSize() const +{ + return d_recordBufferSize; +} + +inline const bsl::string& LogDumpConfig::recordingLevel() const +{ + return d_recordingLevel; +} + +inline const bsl::string& LogDumpConfig::triggerLevel() const +{ + return d_triggerLevel; +} + // ------------------------------- // class MasterAssignmentAlgorithm // ------------------------------- @@ -13497,6 +13934,7 @@ void LogController::hashAppendImpl(t_HASH_ALGORITHM& hashAlgorithm) const hashAppend(hashAlgorithm, this->consoleSeverityThreshold()); hashAppend(hashAlgorithm, this->categories()); hashAppend(hashAlgorithm, this->syslog()); + hashAppend(hashAlgorithm, this->logDump()); } inline bool LogController::isEqualTo(const LogController& rhs) const @@ -13512,7 +13950,7 @@ inline bool LogController::isEqualTo(const LogController& rhs) const this->consoleSeverityThreshold() == rhs.consoleSeverityThreshold() && this->categories() == rhs.categories() && - this->syslog() == rhs.syslog(); + this->syslog() == rhs.syslog() && this->logDump() == rhs.logDump(); } // CLASS METHODS @@ -13583,6 +14021,12 @@ int LogController::manipulateAttributes(t_MANIPULATOR& manipulator) return ret; } + ret = manipulator(&d_logDump, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_LOG_DUMP]); + if (ret) { + return ret; + } + return 0; } @@ -13639,6 +14083,10 @@ int LogController::manipulateAttribute(t_MANIPULATOR& manipulator, int id) return manipulator(&d_syslog, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SYSLOG]); } + case ATTRIBUTE_ID_LOG_DUMP: { + return manipulator(&d_logDump, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_LOG_DUMP]); + } default: return NOT_FOUND; } } @@ -13709,6 +14157,11 @@ inline SyslogConfig& LogController::syslog() return d_syslog; } +inline LogDumpConfig& LogController::logDump() +{ + return d_logDump; +} + // ACCESSORS template int LogController::accessAttributes(t_ACCESSOR& accessor) const @@ -13776,6 +14229,11 @@ int LogController::accessAttributes(t_ACCESSOR& accessor) const return ret; } + ret = accessor(d_logDump, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_LOG_DUMP]); + if (ret) { + return ret; + } + return 0; } @@ -13829,6 +14287,10 @@ int LogController::accessAttribute(t_ACCESSOR& accessor, int id) const return accessor(d_syslog, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SYSLOG]); } + case ATTRIBUTE_ID_LOG_DUMP: { + return accessor(d_logDump, + ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_LOG_DUMP]); + } default: return NOT_FOUND; } } @@ -13899,6 +14361,11 @@ inline const SyslogConfig& LogController::syslog() const return d_syslog; } +inline const LogDumpConfig& LogController::logDump() const +{ + return d_logDump; +} + // ----------------------- // class NetworkInterfaces // ----------------------- @@ -17688,6 +18155,13 @@ inline const AppConfig& Configuration::appConfig() const } // close enterprise namespace #endif -// GENERATED BY @BLP_BAS_CODEGEN_VERSION@ +// GENERATED BY BLP_BAS_CODEGEN_2024.09.20 // USING bas_codegen.pl -m msg --noAggregateConversion --noExternalization // --noIdent --package mqbcfg --msgComponent messages mqbcfg.xsd +// ---------------------------------------------------------------------------- +// NOTICE: +// Copyright 2024 Bloomberg Finance L.P. All rights reserved. +// Property of Bloomberg Finance L.P. (BFLP) +// This software is made available solely pursuant to the +// terms of a BFLP license agreement which governs its use. +// ------------------------------- END-OF-FILE -------------------------------- diff --git a/src/groups/mwc/mwctsk/mwctsk_logcontroller.cpp b/src/groups/mwc/mwctsk/mwctsk_logcontroller.cpp index fcdf594e2f..d9c73f2971 100644 --- a/src/groups/mwc/mwctsk/mwctsk_logcontroller.cpp +++ b/src/groups/mwc/mwctsk/mwctsk_logcontroller.cpp @@ -651,7 +651,7 @@ int LogController::initialize(bsl::ostream& errorDescription, bdlf::PlaceHolders::_4, bdlf::PlaceHolders::_5, '.')); - rc = lmc.setDefaultRecordBufferSizeIfValid(32768); + rc = lmc.setDefaultRecordBufferSizeIfValid(config.recordBufferSize()); if (rc != 0) { errorDescription << "Unable to set default record buffer size on lmc " << "[rc: " << rc << "]"; @@ -741,7 +741,9 @@ int LogController::initialize(bsl::ostream& errorDescription, // ------------- // Configuration - setVerbosityLevel(config.loggingVerbosity()); + setVerbosityLevel(config.loggingVerbosity(), + config.recordingVerbosity(), + config.triggerVerbosity()); const LogControllerConfig::CategoryPropertiesMap& categories = config.categoriesProperties(); @@ -829,18 +831,20 @@ void LogController::shutdown() d_isInitialized = false; } -void LogController::setVerbosityLevel(ball::Severity::Level verbosity) +void LogController::setVerbosityLevel(ball::Severity::Level passVerbosity, + ball::Severity::Level recordVerbosity, + ball::Severity::Level triggerVerbosity) { ball::Administration::setDefaultThresholdLevels( - ball::Severity::OFF, // recording level - verbosity, // passthrough level - ball::Severity::OFF, // trigger level + recordVerbosity, // recording level + passVerbosity, // passthrough level + triggerVerbosity, // trigger level ball::Severity::OFF); // triggerAll level ball::Administration::setThresholdLevels( "*", - ball::Severity::OFF, // recording level - verbosity, // passthrough level - ball::Severity::OFF, // trigger level + recordVerbosity, // recording level + passVerbosity, // passthrough level + triggerVerbosity, // trigger level ball::Severity::OFF); // triggerAll level } diff --git a/src/groups/mwc/mwctsk/mwctsk_logcontroller.h b/src/groups/mwc/mwctsk/mwctsk_logcontroller.h index a966ea638d..a3ad6aa520 100644 --- a/src/groups/mwc/mwctsk/mwctsk_logcontroller.h +++ b/src/groups/mwc/mwctsk/mwctsk_logcontroller.h @@ -229,6 +229,20 @@ class LogControllerConfig { CategoryPropertiesMap d_categories; // Map of category properties + int d_recordBufferSize; + // Size in bytes of the logger's record buffer + + ball::Severity::Level d_recordingVerbosity; + // If the severity level of the record is at least as severe as the + // d_recordingVerbosity, then the record will be stored by the logger in + // its log record buffer (i.e., it will be recorded). + + ball::Severity::Level d_triggerVerbosity; + // If the severity of the record is at least as severe as the + // d_triggerVerbosity, then the record will cause immediate publication + // of that record and any records in the logger's log record buffer (i.e., + // this record will trigger a log record dump). + private: /// Convert specified BALL severity `level` to the corresponding /// BSLS_LOG severity level. @@ -271,6 +285,7 @@ class LogControllerConfig { LogControllerConfig& setSyslogEnabled(bool value); LogControllerConfig& setSyslogFormat(const bslstl::StringRef& value); LogControllerConfig& setSyslogAppName(const bslstl::StringRef& value); + LogControllerConfig& setRecordBufferSize(int value); /// Set the corresponding attribute to the specified `value` and return /// a reference offering modifiable access to this object. @@ -318,6 +333,9 @@ class LogControllerConfig { const bsl::string& syslogFormat() const; const bsl::string& syslogAppName() const; ball::Severity::Level syslogVerbosity() const; + int recordBufferSize() const; + ball::Severity::Level recordingVerbosity() const; + ball::Severity::Level triggerVerbosity() const; /// Return the value of the corresponding attribute. const CategoryPropertiesMap& categoriesProperties() const; @@ -458,11 +476,18 @@ class LogController { /// will no longer be available. void shutdown(); - /// Change the logging severity threshold to the specified `verbosity`: - /// any record with a severity of at least `verbosity` will be printed - /// to the log file, and eventually to the console if the configured - /// console severity threshold allows it. - void setVerbosityLevel(ball::Severity::Level verbosity); + /// Change the logging severity threshold to the specified verbosity + /// levels: any record with a severity of at least `passVerbosity` will + /// be printed immediately to the log file, and eventually to the + /// console if the configured console severity threshold allows it. + /// any record with a severity of at least `recordingVerbosity` will be + /// stored by the logger in its log record buffer. Any record with a + /// severity of at least `triggerVerbosity` will cause immediate + /// publication of that record and any records in the logger's buffer. + void setVerbosityLevel( + ball::Severity::Level passVerbosity, + ball::Severity::Level recordVerbosity = ball::Severity::OFF, + ball::Severity::Level triggerVerbosity = ball::Severity::OFF); /// Change the verbosity of the specified `category` to the specified /// `verbosity`. `category` can be an expression, with a terminating @@ -514,7 +539,8 @@ int LogControllerConfig::fromObj(bsl::ostream& errorDescription, .setConsoleFormat(obj.consoleFormat()) .setSyslogEnabled(obj.syslog().enabled()) .setSyslogAppName(obj.syslog().appName()) - .setSyslogFormat(obj.syslog().logFormat()); + .setSyslogFormat(obj.syslog().logFormat()) + .setRecordBufferSize(obj.logDump().recordBufferSize()); if (ball::SeverityUtil::fromAsciiCaseless( &d_loggingVerbosity, @@ -524,6 +550,22 @@ int LogControllerConfig::fromObj(bsl::ostream& errorDescription, return -1; // RETURN } + if (ball::SeverityUtil::fromAsciiCaseless( + &d_recordingVerbosity, + obj.logDump().recordingLevel().c_str()) != 0) { + errorDescription << "Invalid value for 'recordingLevel' ('" + << obj.logDump().recordingLevel() << "')"; + return -1; // RETURN + } + + if (ball::SeverityUtil::fromAsciiCaseless( + &d_triggerVerbosity, + obj.logDump().triggerLevel().c_str()) != 0) { + errorDescription << "Invalid value for 'triggerLevel' ('" + << obj.logDump().triggerLevel() << "')"; + return -1; // RETURN + } + ball::Severity::Level bslsSeverityAsBal = ball::Severity::e_ERROR; // TODO: enforcing 'obj' to have 'bslsLogSeverityThreshold' accessor is a // backward incompatible change from build perspective, and will require a @@ -653,6 +695,12 @@ LogControllerConfig::setSyslogAppName(const bslstl::StringRef& value) return *this; } +inline LogControllerConfig& LogControllerConfig::setRecordBufferSize(int value) +{ + d_recordBufferSize = value; + return *this; +} + inline LogControllerConfig& LogControllerConfig::setSyslogVerbosity(ball::Severity::Level value) { @@ -727,6 +775,21 @@ inline ball::Severity::Level LogControllerConfig::syslogVerbosity() const return d_syslogVerbosity; } +inline int LogControllerConfig::recordBufferSize() const +{ + return d_recordBufferSize; +} + +inline ball::Severity::Level LogControllerConfig::recordingVerbosity() const +{ + return d_recordingVerbosity; +} + +inline ball::Severity::Level LogControllerConfig::triggerVerbosity() const +{ + return d_triggerVerbosity; +} + inline const LogControllerConfig::CategoryPropertiesMap& LogControllerConfig::categoriesProperties() const {