mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-16 00:45:48 +08:00
remove minor optimization for the sake of simplicity
This commit is contained in:
parent
e41b92c55a
commit
4f65fcd7b1
@ -35,16 +35,13 @@ public:
|
|||||||
: base_filename_(std::move(base_filename))
|
: base_filename_(std::move(base_filename))
|
||||||
, max_size_(max_size)
|
, max_size_(max_size)
|
||||||
, max_files_(max_files)
|
, max_files_(max_files)
|
||||||
{
|
|
||||||
if (rotate_on_open)
|
|
||||||
{
|
|
||||||
rotate_(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
file_helper_.open(calc_filename(base_filename_, 0));
|
file_helper_.open(calc_filename(base_filename_, 0));
|
||||||
}
|
|
||||||
current_size_ = file_helper_.size(); // expensive. called only once
|
current_size_ = file_helper_.size(); // expensive. called only once
|
||||||
|
if (rotate_on_open && current_size_ > 0)
|
||||||
|
{
|
||||||
|
rotate_();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// calc filename according to index and file extension if exists.
|
// calc filename according to index and file extension if exists.
|
||||||
@ -95,7 +92,7 @@ private:
|
|||||||
// log.1.txt -> log.2.txt
|
// log.1.txt -> log.2.txt
|
||||||
// log.2.txt -> log.3.txt
|
// log.2.txt -> log.3.txt
|
||||||
// log.3.txt -> delete
|
// log.3.txt -> delete
|
||||||
void rotate_(bool reopen=true)
|
void rotate_()
|
||||||
{
|
{
|
||||||
using details::os::filename_to_str;
|
using details::os::filename_to_str;
|
||||||
file_helper_.close();
|
file_helper_.close();
|
||||||
@ -123,15 +120,8 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reopen)
|
|
||||||
{
|
|
||||||
file_helper_.reopen(true);
|
file_helper_.reopen(true);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
file_helper_.open(base_filename_, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete the target if exists, and rename the src file to target
|
// delete the target if exists, and rename the src file to target
|
||||||
// return true on success, false otherwise.
|
// return true on success, false otherwise.
|
||||||
|
Loading…
Reference in New Issue
Block a user