mirror of
https://github.com/google/nomulus
synced 2026-01-03 03:35:42 +00:00
Removing leading newline from GKE log messages (#2454)
GKE now displays log messages correctly. There is no need for an extra leading newline, which now results in a useless blank line for each log entry in Log Explorer.
This commit is contained in:
@@ -101,11 +101,6 @@ public class GcpJsonFormatter extends Formatter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String format(LogRecord record) {
|
public String format(LogRecord record) {
|
||||||
// Add an extra newline before the message for better displaying of multi-line logs. To see the
|
|
||||||
// correctly indented multi-line logs, expand the log and look for the textPayload field. This
|
|
||||||
// newline makes sure that the entire message starts on its own line, so that indentation within
|
|
||||||
// the message is correct.
|
|
||||||
|
|
||||||
String severity = severityFor(record.getLevel());
|
String severity = severityFor(record.getLevel());
|
||||||
|
|
||||||
// The rest is mostly lifted from java.util.logging.SimpleFormatter.
|
// The rest is mostly lifted from java.util.logging.SimpleFormatter.
|
||||||
@@ -119,7 +114,7 @@ public class GcpJsonFormatter extends Formatter {
|
|||||||
throwable = sw.toString();
|
throwable = sw.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
String message = '\n' + formatMessage(record);
|
String message = formatMessage(record);
|
||||||
|
|
||||||
String function = "";
|
String function = "";
|
||||||
if (record.getSourceClassName() != null) {
|
if (record.getSourceClassName() != null) {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class GcpJsonFormatterTest {
|
|||||||
|
|
||||||
private static final String LOG_TEMPLATE =
|
private static final String LOG_TEMPLATE =
|
||||||
"""
|
"""
|
||||||
{"severity":"@@SEVERITY@@","logging.googleapis.com/sourceLocation":{"file":"GcpJsonFormatterTest.java","line":"@@LINE@@","function":"google.registry.util.GcpJsonFormatterTest.@@FUNCTION@@"},"message":"\\n@@MESSAGE@@"}
|
{"severity":"@@SEVERITY@@","logging.googleapis.com/sourceLocation":{"file":"GcpJsonFormatterTest.java","line":"@@LINE@@","function":"google.registry.util.GcpJsonFormatterTest.@@FUNCTION@@"},"message":"@@MESSAGE@@"}
|
||||||
""";
|
""";
|
||||||
|
|
||||||
private static String makeJson(String severity, int line, String function, String message) {
|
private static String makeJson(String severity, int line, String function, String message) {
|
||||||
|
|||||||
Reference in New Issue
Block a user