1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

bugfixes + tonlib update

This commit is contained in:
ton 2020-04-30 15:04:47 +04:00
parent 2f81361a02
commit eecf05ca59
35 changed files with 734 additions and 193 deletions

View file

@ -95,7 +95,7 @@ void FileLog::append(CSlice cslice, int log_level) {
process_fatal_error(cslice);
}
if (size_ > rotate_threshold_) {
if (size_ > rotate_threshold_ || want_rotate_.load(std::memory_order_relaxed)) {
auto status = rename(path_, PSLICE() << path_ << ".old");
if (status.is_error()) {
process_fatal_error(PSLICE() << status.error() << " in " << __FILE__ << " at " << __LINE__);
@ -111,9 +111,13 @@ void FileLog::rotate() {
do_rotate();
}
void FileLog::lazy_rotate() {
want_rotate_ = true;
}
void FileLog::do_rotate() {
auto current_verbosity_level = GET_VERBOSITY_LEVEL();
SET_VERBOSITY_LEVEL(std::numeric_limits<int>::min()); // to ensure that nothing will be printed to the closed log
want_rotate_ = false;
td::ScopedDisableLog disable_log; // to ensure that nothing will be printed to the closed log
CHECK(!path_.empty());
fd_.close();
auto r_fd = FileFd::open(path_, FileFd::Create | FileFd::Truncate | FileFd::Write);
@ -125,7 +129,6 @@ void FileLog::do_rotate() {
fd_.get_native_fd().duplicate(Stderr().get_native_fd()).ignore();
}
size_ = 0;
SET_VERBOSITY_LEVEL(current_verbosity_level);
}
Result<td::unique_ptr<LogInterface>> FileLog::create(string path, int64 rotate_threshold, bool redirect_stderr) {