Rename LogInterface::rotate to after_rotation.
This commit is contained in:
parent
fdeaafa70d
commit
8231c58335
@ -62,12 +62,12 @@ class CombinedLog : public LogInterface {
|
||||
}
|
||||
}
|
||||
|
||||
void rotate() final {
|
||||
void after_rotation() final {
|
||||
if (first_) {
|
||||
first_->rotate();
|
||||
first_->after_rotation();
|
||||
}
|
||||
if (second_) {
|
||||
second_->rotate();
|
||||
second_->after_rotation();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ void FileLog::do_append(int log_level, CSlice slice) {
|
||||
if (status.is_error()) {
|
||||
process_fatal_error(PSLICE() << status.error() << " in " << __FILE__ << " at " << __LINE__);
|
||||
}
|
||||
do_rotate();
|
||||
do_after_rotation();
|
||||
}
|
||||
while (!slice.empty()) {
|
||||
auto r_size = fd_.write(slice);
|
||||
@ -89,18 +89,18 @@ void FileLog::do_append(int log_level, CSlice slice) {
|
||||
}
|
||||
}
|
||||
|
||||
void FileLog::rotate() {
|
||||
void FileLog::after_rotation() {
|
||||
if (path_.empty()) {
|
||||
return;
|
||||
}
|
||||
do_rotate();
|
||||
do_after_rotation();
|
||||
}
|
||||
|
||||
void FileLog::lazy_rotate() {
|
||||
want_rotate_ = true;
|
||||
}
|
||||
|
||||
void FileLog::do_rotate() {
|
||||
void FileLog::do_after_rotation() {
|
||||
want_rotate_ = false;
|
||||
ScopedDisableLog disable_log; // to ensure that nothing will be printed to the closed log
|
||||
CHECK(!path_.empty());
|
||||
|
@ -34,7 +34,7 @@ class FileLog : public LogInterface {
|
||||
|
||||
bool get_redirect_stderr() const;
|
||||
|
||||
void rotate() final;
|
||||
void after_rotation() final;
|
||||
|
||||
void lazy_rotate();
|
||||
|
||||
@ -48,7 +48,7 @@ class FileLog : public LogInterface {
|
||||
|
||||
void do_append(int log_level, CSlice slice) final;
|
||||
|
||||
void do_rotate();
|
||||
void do_after_rotation();
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
@ -33,6 +33,14 @@ class TsFileLog : public LogInterface {
|
||||
return init_info(&logs_[0]);
|
||||
}
|
||||
|
||||
void rotate() {
|
||||
for (auto &info : logs_) {
|
||||
if (info.is_inited.load(std::memory_order_acquire)) {
|
||||
info.log.lazy_rotate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
struct Info {
|
||||
FileLog log;
|
||||
@ -79,14 +87,6 @@ class TsFileLog : public LogInterface {
|
||||
get_current_logger()->do_append(log_level, slice);
|
||||
}
|
||||
|
||||
void rotate() final {
|
||||
for (auto &info : logs_) {
|
||||
if (info.is_inited.load(std::memory_order_acquire)) {
|
||||
info.log.lazy_rotate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> get_file_paths() final {
|
||||
vector<string> res;
|
||||
for (auto &log : logs_) {
|
||||
|
@ -59,8 +59,6 @@
|
||||
#define VLOG(level) LOG_IMPL(DEBUG, level, true, TD_DEFINE_STR(level))
|
||||
#define VLOG_IF(level, condition) LOG_IMPL(DEBUG, level, condition, TD_DEFINE_STR(level) " " #condition)
|
||||
|
||||
#define LOG_ROTATE() ::td::log_interface->rotate()
|
||||
|
||||
#define LOG_TAG ::td::Logger::tag_
|
||||
#define LOG_TAG2 ::td::Logger::tag2_
|
||||
|
||||
@ -169,7 +167,7 @@ class LogInterface {
|
||||
|
||||
void append(int log_level, CSlice slice);
|
||||
|
||||
virtual void rotate() {
|
||||
virtual void after_rotation() {
|
||||
}
|
||||
|
||||
virtual vector<string> get_file_paths() {
|
||||
@ -278,9 +276,9 @@ class TsLog : public LogInterface {
|
||||
log_ = log;
|
||||
exit_critical();
|
||||
}
|
||||
void rotate() final {
|
||||
void after_rotation() final {
|
||||
enter_critical();
|
||||
log_->rotate();
|
||||
log_->after_rotation();
|
||||
exit_critical();
|
||||
}
|
||||
vector<string> get_file_paths() final {
|
||||
|
@ -64,7 +64,7 @@ class LogBenchmark : public td::Benchmark {
|
||||
auto str = PSTRING() << "#" << n << " : fsjklfdjsklfjdsklfjdksl\n";
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (i % 10000 == 0) {
|
||||
log_->rotate();
|
||||
log_->after_rotation();
|
||||
}
|
||||
if (test_full_logging_) {
|
||||
LOG(ERROR) << str;
|
||||
|
Loading…
x
Reference in New Issue
Block a user