New business functions have been added#3
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
Add a new business logger utility to spdlog that routes logs into different files based on business type.
Each business type writes to its own rotating log file, with 30MB max per file and up to 3 files retained.
Supported business types:
Motivation / Background
In some applications we need to separate logs by business domain to make troubleshooting easier.
This PR introduces a small business logging layer on top of spdlog, allowing callers to pass a business tag/type and have logs automatically written to the corresponding log file with rotation/retention.
What’s included
New files
include/spdlog/business_logger.hDefines business types and the
BusinessLoggermanager API.src/business_logger.cppImplements the business logger manager and sink/file creation.
example/business_logger_example.cppDemonstrates usage and generates expected business log files.
tests/test_business_logger.cppCatch2 tests validating business log routing and setup.
Modified files
include/spdlog/spdlog.hIncludes
business_logger.hso users can access the new feature by including<spdlog/spdlog.h>.CMakeLists.txtAdds
src/business_logger.cppinto the build.example/CMakeLists.txtAdds build target for
business_logger_example(and removes duplicate entries introduced during iteration).tests/CMakeLists.txtAdds
test_business_logger.cppinto the unit test target.API / Usage
Typical usage:
Call
spdlog::business::BusinessLogger::instance().log(...)Provide business type + message (supports multiple log levels: trace/debug/info/warn/err/critical)
Logs are routed into per-business files, with rotation:
How to test
Build + run example + run tests:
cd build cmake .. -DSPDLOG_BUILD_TESTS=ON make ./example/business_logger_example ./tests/spdlog-utestsExpected result:
screen_recording.txt,desktop_opening.txt,keyboard_recording.txt,audio_recording.txtdepending on the configured naming/path).spdlog-utests.Notes
src/spdlog.cppwas reviewed and not modified (it mainly contains template instantiations); build integration is handled via CMake instead.<iostream>include.Checklist