Fix log size after rotation.
This commit is contained in:
parent
4f737910ab
commit
b11a5b8ad4
@ -49,7 +49,12 @@ Status AsyncFileLog::init(string path, int64 rotate_threshold, bool redirect_std
|
||||
if (!Stderr().empty() && redirect_stderr) {
|
||||
fd.get_native_fd().duplicate(Stderr().get_native_fd()).ignore();
|
||||
}
|
||||
size = 0;
|
||||
auto r_size = fd.get_size();
|
||||
if (r_fd.is_error()) {
|
||||
process_fatal_error(PSLICE() << "Failed to get log size: " << r_fd.error() << " in " << __FILE__ << " at "
|
||||
<< __LINE__ << '\n');
|
||||
}
|
||||
size = r_size.move_as_ok();
|
||||
};
|
||||
auto append = [&](CSlice slice) {
|
||||
if (size > rotate_threshold) {
|
||||
|
@ -128,7 +128,12 @@ void FileLog::do_after_rotation() {
|
||||
if (!Stderr().empty() && redirect_stderr_) {
|
||||
fd_.get_native_fd().duplicate(Stderr().get_native_fd()).ignore();
|
||||
}
|
||||
size_ = 0;
|
||||
auto r_size = fd_.get_size();
|
||||
if (r_fd.is_error()) {
|
||||
process_fatal_error(PSLICE() << "Failed to get log size: " << r_fd.error() << " in " << __FILE__ << " at "
|
||||
<< __LINE__ << '\n');
|
||||
}
|
||||
size_ = r_size.move_as_ok();
|
||||
}
|
||||
|
||||
Result<unique_ptr<LogInterface>> FileLog::create(string path, int64 rotate_threshold, bool redirect_stderr) {
|
||||
|
Loading…
Reference in New Issue
Block a user