Skip to content

New business functions have been added#3

Open
Gotnhub wants to merge 1 commit into
v1.xfrom
feat/my-change-db
Open

New business functions have been added#3
Gotnhub wants to merge 1 commit into
v1.xfrom
feat/my-change-db

Conversation

@Gotnhub

@Gotnhub Gotnhub commented Mar 5, 2026

Copy link
Copy Markdown
Owner

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:

  • Screen recording
  • Desktop opening
  • Keyboard recording
  • Audio recording

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.h
    Defines business types and the BusinessLogger manager API.
  • src/business_logger.cpp
    Implements the business logger manager and sink/file creation.
  • example/business_logger_example.cpp
    Demonstrates usage and generates expected business log files.
  • tests/test_business_logger.cpp
    Catch2 tests validating business log routing and setup.

Modified files

  • include/spdlog/spdlog.h
    Includes business_logger.h so users can access the new feature by including <spdlog/spdlog.h>.
  • CMakeLists.txt
    Adds src/business_logger.cpp into the build.
  • example/CMakeLists.txt
    Adds build target for business_logger_example (and removes duplicate entries introduced during iteration).
  • tests/CMakeLists.txt
    Adds test_business_logger.cpp into 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:

    • max file size: 30MB
    • max files per business: 3

How to test

Build + run example + run tests:

cd build
cmake .. -DSPDLOG_BUILD_TESTS=ON
make
./example/business_logger_example
./tests/spdlog-utests

Expected result:

  • Example runs successfully and creates per-business log files (e.g. screen_recording.txt, desktop_opening.txt, keyboard_recording.txt, audio_recording.txt depending on the configured naming/path).
  • Unit tests pass via spdlog-utests.

Notes

  • src/spdlog.cpp was reviewed and not modified (it mainly contains template instantiations); build integration is handled via CMake instead.
  • Fixed a build issue in the example by adding missing <iostream> include.

Checklist

  • Added new feature (business log routing)
  • Added example demonstrating usage
  • Added unit tests (Catch2)
  • Integrated into build system (CMake)
  • Verified by local build + running example + running tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant