forked from linkerd/linkerd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the system configured timezone when formatting logs (linkerd#1833)
Signed-off-by: fantayeneh <[email protected]>
- Loading branch information
1 parent
d32350b
commit 4a9222d
Showing
2 changed files
with
41 additions
and
4 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
34 changes: 34 additions & 0 deletions
34
admin/src/test/scala/io/buoyant/admin/LogFormatterTest.scala
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,34 @@ | ||
package io.buoyant.admin | ||
|
||
import java.util.TimeZone | ||
import java.util.logging.{Level, LogRecord} | ||
|
||
import com.twitter.util.TimeFormat | ||
import org.scalatest.WordSpec | ||
|
||
class LogFormatterTest extends WordSpec { | ||
|
||
val record = new LogRecord(Level.INFO, "Logging useful info") | ||
record.setMillis(1519468460239L) | ||
record.setThreadID(10) | ||
|
||
"LogFormatter" should { | ||
|
||
"use UTC timezone" in { | ||
val utcFormatter = new LogFormatter( | ||
new TimeFormat(" MMdd HH:mm:ss.SSS z", TimeZone.getTimeZone("UTC")) | ||
) | ||
assert(utcFormatter | ||
.format(record) == "I 0224 10:34:20.239 UTC THREAD10: Logging useful info\n") | ||
} | ||
|
||
"use non UTC timezone" in { | ||
val utcFormatter = new LogFormatter( | ||
new TimeFormat(" MMdd HH:mm:ss.SSS z", TimeZone.getTimeZone("GMT+8")) | ||
) | ||
assert(utcFormatter | ||
.format(record) == "I 0224 18:34:20.239 GMT+08:00 THREAD10: Logging useful info\n") | ||
} | ||
|
||
} | ||
} |