-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable log message output for messages larger than 4096 bytes.
PiperOrigin-RevId: 705879341
- Loading branch information
1 parent
cc8bfd7
commit 91baa9b
Showing
6 changed files
with
84 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "mediapipe/framework/vlog_utils.h" | ||
|
||
#include "absl/log/absl_log.h" | ||
#include "absl/log/log.h" | ||
#include "absl/strings/str_split.h" // IWYU pragma: keep | ||
#include "absl/strings/string_view.h" | ||
#include "mediapipe/framework/port/logging.h" | ||
|
||
namespace mediapipe { | ||
|
||
void VlogLargeMessage(int verbose_level, absl::string_view message) { | ||
#if defined(MEDIAPIPE_MOBILE) | ||
if (message.size() > 4096) { | ||
for (const auto& line : absl::StrSplit(message, '\n')) { | ||
VLOG(verbose_level) << line; | ||
} | ||
return; | ||
} | ||
#endif | ||
VLOG(verbose_level) << message; | ||
} | ||
|
||
} // namespace mediapipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef MEDIAPIPE_FRAMEWORK_VLOG_UTILS_H_ | ||
#define MEDIAPIPE_FRAMEWORK_VLOG_UTILS_H_ | ||
|
||
#include "absl/strings/string_view.h" | ||
|
||
namespace mediapipe { | ||
|
||
// Helper to log a message with a large number of lines on mobile (Android). | ||
// | ||
// On Android, the logcat will truncate the log if the message is larger than | ||
// 4096 bytes. This function splits the message by new lines and logs each | ||
// line separately. To ensure the log message is only generated when VLOG is | ||
// turned on, use this function in a VLOG_IS_ON() block: | ||
// if (VLOG_IS_ON(1)) { | ||
// VlogLargeMessage( | ||
// /*verbose_level=*/1, GenerateDebugString()); | ||
// } | ||
void VlogLargeMessage(int verbose_level, absl::string_view message); | ||
|
||
} // namespace mediapipe | ||
|
||
#endif // MEDIAPIPE_FRAMEWORK_VLOG_UTILS_H_ |