Added new business functions#2
Open
Gotnhub wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a new sink,
business_rotating_sink, which routes log messages to different rotating log files based on a business tag/identifier. Each business has its own independent rotation state (max file size 30MB, max 3 rotated files kept). The implementation follows spdlog’s existing sink patterns (mt/st variants, header +-inl.hsplit), and includes unit tests integrated into the test build.Motivation
In applications where multiple business modules share the same logging infrastructure, it’s often necessary to:
Changes
Added
include/spdlog/sinks/business_rotating_sink.hDeclares
business_rotating_sinkand factory helpers.include/spdlog/sinks/business_rotating_sink-inl.hInline implementation for template code (matches spdlog conventions).
tests/test_business_rotating_sink.cppNew unit tests (8 test cases).
Modified
src/file_sinks.cppAdds template instantiations for
business_rotating_sink(consistent with existing file sinks).tests/CMakeLists.txtRegisters the new test source in the test target.
tests/includes.hAdds the required include for the new sink header.
Implementation Notes
business_rotating_sink_mtandbusiness_rotating_sink_st, aligning with spdlog’s mt/st naming and threading model.rotating_file_sinkper business tag: each tag maps to its own rotating sink instance, maintaining independent file names and rotation state.sink_it_is implemented to avoid re-acquiring locks and prevents nested locking scenarios that could lead to deadlocks.*.h+*-inl.hsplit to keep template implementation in headers while preserving readability and build behavior.Testing
[business_rotating_sink])Notes
This is an additive feature and should not affect existing sinks or behavior.