Skip to content

Commit

Permalink
CloudJsonLoggingAppender: fix illegal characters in log names
Browse files Browse the repository at this point in the history
  • Loading branch information
nafg authored Jan 30, 2019
1 parent e269256 commit 92669ba
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ object CloudJsonLoggingAppender {
m.getName
}

val legalNameChars = ('a' to 'z').toSet ++ ('A' to 'Z') ++ ('0' to '9') ++ Set('/', '_', '-', '.')
def legalizeNameChar(c: Char) = if (legalNameChars(c)) c else '-'

def logEntryFor(e: ILoggingEvent) = {
val level = e.getLevel

Expand Down Expand Up @@ -133,7 +136,7 @@ object CloudJsonLoggingAppender {

LogEntry
.newBuilder(Payload.JsonPayload.of(payload.asJava))
.setLogName(e.getLoggerName)
.setLogName(e.getLoggerName.map(legalizeNameChar))
.setTimestamp(e.getTimeStamp)
.setSeverity(severityFor(level))
.setLabels(labels.asJava)
Expand Down

0 comments on commit 92669ba

Please sign in to comment.