mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 18:11:33 +08:00
small updates
This commit is contained in:
parent
e5f4790407
commit
ae9d88dbb3
@ -24,7 +24,7 @@ int main(int argc, char* argv[])
|
|||||||
console->set_level(c11log::level::INFO);
|
console->set_level(c11log::level::INFO);
|
||||||
console->info("Starting bench with", howmany, "iterations..");
|
console->info("Starting bench with", howmany, "iterations..");
|
||||||
|
|
||||||
auto bench = c11log::create<sinks::rotating_file_sink_st>("bench", "myrotating", "txt", 1024 * 1024 * 5, 3, 0);
|
auto bench = c11log::create<sinks::rotating_file_sink_st>("bench", "myrotating", "txt", 1024 * 1024 * 1, 3, 0);
|
||||||
|
|
||||||
//auto bench = c11log::create<sinks::simple_file_sink_st>("bench", "simplelog.txt", 1);
|
//auto bench = c11log::create<sinks::simple_file_sink_st>("bench", "simplelog.txt", 1);
|
||||||
//auto bench = c11log::create<sinks::null_sink_st>("bench");
|
//auto bench = c11log::create<sinks::null_sink_st>("bench");
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
//
|
||||||
|
// base sink templated over a mutex (either dummy or realy)
|
||||||
|
// concrete implementation should only overrid the _sink_it method.
|
||||||
|
// all locking is taken care of here so no locking needed by the implementors..
|
||||||
|
//
|
||||||
|
|
||||||
#include<string>
|
#include<string>
|
||||||
#include<mutex>
|
#include<mutex>
|
||||||
|
@ -86,20 +86,18 @@ private:
|
|||||||
|
|
||||||
// Rotate files:
|
// Rotate files:
|
||||||
// log.txt -> log.1.txt
|
// log.txt -> log.1.txt
|
||||||
// ..
|
// log.1.txt -> log2.txt
|
||||||
// log.n.txt -> log.n+1.txt
|
// log.2.txt -> log3.txt
|
||||||
|
// log.3.txt -> delete
|
||||||
|
|
||||||
|
|
||||||
void _rotate()
|
void _rotate()
|
||||||
{
|
{
|
||||||
_file_helper.close();
|
_file_helper.close();
|
||||||
//Remove oldest file
|
|
||||||
for (auto i = _max_files; i > 0; --i)
|
for (auto i = _max_files; i > 0; --i)
|
||||||
{
|
{
|
||||||
std::string src = _calc_filename(_base_filename, i - 1, _extension);
|
std::string src = _calc_filename(_base_filename, i - 1, _extension);
|
||||||
std::string target = _calc_filename(_base_filename, i, _extension);
|
std::string target = _calc_filename(_base_filename, i, _extension);
|
||||||
if (i == _max_files)
|
|
||||||
std::remove(target.c_str());
|
|
||||||
std::rename(src.c_str(), target.c_str());
|
std::rename(src.c_str(), target.c_str());
|
||||||
}
|
}
|
||||||
_file_helper.open(_calc_filename(_base_filename, 0, _extension));
|
_file_helper.open(_calc_filename(_base_filename, 0, _extension));
|
||||||
|
Loading…
Reference in New Issue
Block a user