Skip to content

Commit

Permalink
airframe-log: Create stderr explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial committed Jul 9, 2021
1 parent b90b901 commit 6b9cdaa
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions airframe-log/.jvm/src/main/scala/wvlet/log/LogEnv.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package wvlet.log
import java.io.PrintStream
import java.io.{FileDescriptor, FileOutputStream, PrintStream}
import java.lang.management.ManagementFactory

import javax.management.{InstanceAlreadyExistsException, ObjectName}
import wvlet.log.LogFormatter.SourceCodeLogFormatter

Expand All @@ -11,8 +10,16 @@ private[log] object LogEnv extends LogEnvBase {
override def isScalaJS: Boolean = false
override def defaultLogLevel: LogLevel = LogLevel.INFO

override def defaultConsoleOutput: PrintStream = System.err
override def defaultHandler: java.util.logging.Handler = new ConsoleLogHandler(SourceCodeLogFormatter)
override lazy val defaultConsoleOutput: PrintStream = {
// Note: In normal circumstances, using System.err here is fine, but
// System.err can be replaced with other implementation
// (e.g., airlift.Logging, which is used in Trino https://github.com/airlift/airlift/blob/master/log-manager/src/main/java/io/airlift/log/Logging.java),
// so we create a stderr stream explicitly here.
new PrintStream(new FileOutputStream(FileDescriptor.err))
}
override def defaultHandler: java.util.logging.Handler = {
new ConsoleLogHandler(SourceCodeLogFormatter)
}

/**
* @param cl
Expand Down

0 comments on commit 6b9cdaa

Please sign in to comment.