Skip to content

Commit

Permalink
Feature: mass rotate (#36)
Browse files Browse the repository at this point in the history
* feature: execute rotate on each sink

Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>

* update: bump version

Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>

---------

Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
  • Loading branch information
xDimon authored Oct 28, 2024
1 parent ab67ddb commit 526cede
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cmake_minimum_required(VERSION 3.12)
include("cmake/Hunter/init.cmake")

cmake_policy(SET CMP0048 NEW)
project(soralog VERSION 0.2.2 LANGUAGES CXX)
project(soralog VERSION 0.2.4 LANGUAGES CXX)

find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
Expand Down
5 changes: 5 additions & 0 deletions include/soralog/logging_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ namespace soralog {
*/
bool resetLevelOfLogger(const std::string &logger_name);

/**
* Calls `Sink::rotate()` for all registered sinks
*/
void callRotateForAllSinks();

private:
/**
* @returns loggers (with creating that if it isn't exists yet) with
Expand Down
8 changes: 8 additions & 0 deletions src/logging_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,4 +556,12 @@ namespace soralog {
return false;
}

void LoggingSystem::callRotateForAllSinks() {
std::lock_guard guard(mutex_);
std::ranges::for_each(sinks_, [](const auto &it) {
const auto &sink = it.second;
sink->rotate();
});
}

} // namespace soralog

0 comments on commit 526cede

Please sign in to comment.