Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle --max_log_size overflow #622

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ static const char* GetAnsiColorCode(GLogColor color) {

// Safely get max_log_size, overriding to 1 if it somehow gets defined as 0
static int32 MaxLogSize() {
return (FLAGS_max_log_size > 0 ? FLAGS_max_log_size : 1);
return (FLAGS_max_log_size > 0 && FLAGS_max_log_size < 4096 ? FLAGS_max_log_size : 1);
}

// An arbitrary limit on the length of a single log message. This
Expand Down Expand Up @@ -490,7 +490,7 @@ class LogCleaner {
const string& filename_extension) const;

bool IsLogLastModifiedOver(const string& filepath, int days) const;

bool enabled_;
int overdue_days_;
char dir_delim_; // filepath delimiter ('/' or '\\')
Expand Down Expand Up @@ -1230,7 +1230,7 @@ void LogFileObject::Write(bool force_flush,
file_length_ += header_len;
bytes_since_flush_ += header_len;
}

// Write to LOG file
if ( !stop_writing ) {
// fwrite() doesn't return an error when the disk is full, for
Expand Down Expand Up @@ -1660,7 +1660,7 @@ int AndroidLogLevel(const int severity) {
}
}
#endif // defined(__ANDROID__)
} // namespace
} // namespace

// Flush buffered message, called by the destructor, or any other function
// that needs to synchronize the log.
Expand Down Expand Up @@ -1696,13 +1696,13 @@ void LogMessage::Flush() {
++num_messages_[static_cast<int>(data_->severity_)];
}
LogDestination::WaitForSinks(data_);

#if defined(__ANDROID__)
const int level = AndroidLogLevel((int)data_->severity_);
const std::string text = std::string(data_->message_text_);
__android_log_write(level, "native", text.substr(0,data_->num_chars_to_log_).c_str());
#endif // defined(__ANDROID__)

if (append_newline) {
// Fix the ostrstream back how it was before we screwed with it.
// It's 99.44% certain that we don't need to worry about doing this.
Expand Down