Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 42ee2e4f authored by Tom Cherry's avatar Tom Cherry
Browse files

libbase: Have LogdLogger use LOGGER_ENTRY_MAX_PAYLOAD for its buffer

LogdLogger has its own buffer for adding the file and line number to
FATAL messages, but it is much lower than LOGGER_ENTRY_MAX_PAYLOAD and
that causes problems now that more logs are piped through this logger,
so increase the limit to maximum.

Also, in the case that the file and line number are not added, simply
pass the buffer through to liblog, since there is no reason to copy to
a separate buffer.

Bug: 148678509
Test: build, unit tests
Change-Id: I064aa34641e784dca6c529c51cb192069821d64a
parent 838b1a1f
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -340,18 +340,18 @@ void LogdLogger::operator()(LogId id, LogSeverity severity, const char* tag,


  int lg_id = LogIdTolog_id_t(id);
  int lg_id = LogIdTolog_id_t(id);


  char log_message[1024];
  char log_message_with_file[4068];  // LOGGER_ENTRY_MAX_PAYLOAD, not available in the NDK.
  if (priority == ANDROID_LOG_FATAL && file != nullptr) {
  if (priority == ANDROID_LOG_FATAL && file != nullptr) {
    snprintf(log_message, sizeof(log_message), "%s:%u] %s", file, line, message);
    snprintf(log_message_with_file, sizeof(log_message_with_file), "%s:%u] %s", file, line,
  } else {
             message);
    snprintf(log_message, sizeof(log_message), "%s", message);
    message = log_message_with_file;
  }
  }


  static auto& liblog_functions = GetLibLogFunctions();
  static auto& liblog_functions = GetLibLogFunctions();
  if (liblog_functions) {
  if (liblog_functions) {
    __android_logger_data logger_data = {sizeof(__android_logger_data),     lg_id, priority, tag,
    __android_logger_data logger_data = {sizeof(__android_logger_data),     lg_id, priority, tag,
                                         static_cast<const char*>(nullptr), 0};
                                         static_cast<const char*>(nullptr), 0};
    liblog_functions->__android_log_logd_logger(&logger_data, log_message);
    liblog_functions->__android_log_logd_logger(&logger_data, message);
  } else {
  } else {
    __android_log_buf_print(lg_id, priority, tag, "%s", message);
    __android_log_buf_print(lg_id, priority, tag, "%s", message);
  }
  }