Skip to content

Commit

Permalink
airframe-log: Fixes #2777 Use the default System.err for supporting s…
Browse files Browse the repository at this point in the history
…btn (#2780)

Previously, airframe-log added a workaround for #1756, but it caused
`sbtn` not to show any log output.

By disabling the logging initialization in airlift log-manager, we no
longer need this workaround.
  • Loading branch information
xerial authored Mar 9, 2023
1 parent e83252e commit 13c27fc
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions airframe-log/.jvm/src/main/scala/wvlet/log/LogEnv.scala
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
package wvlet.log
import java.io.{FileDescriptor, FileOutputStream, PrintStream}
import java.lang.management.ManagementFactory
import javax.management.{InstanceAlreadyExistsException, ObjectName, MBeanServer}
import wvlet.log.LogFormatter.SourceCodeLogFormatter

import java.io.PrintStream
import java.lang.management.ManagementFactory
import javax.management.{InstanceAlreadyExistsException, MBeanServer, ObjectName}

/**
*/
private[log] object LogEnv extends LogEnvBase {
override def isScalaJS: Boolean = false
override def defaultLogLevel: LogLevel = LogLevel.INFO

override lazy val defaultConsoleOutput: PrintStream = {
override 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))
// If that happens, we may need to create a stderr stream explicitly like this
// new PrintStream(new FileOutputStream(FileDescriptor.err))

// Use the standard System.err for sbtn native client
System.err
}
override def defaultHandler: java.util.logging.Handler = {
new ConsoleLogHandler(SourceCodeLogFormatter)
Expand All @@ -35,7 +39,6 @@ private[log] object LogEnv extends LogEnvBase {

// When class is an anonymous trait
if (name.contains("$anon$")) {
import collection.JavaConverters._
val interfaces = cl.getInterfaces
if (interfaces != null && interfaces.length > 0) {
// Use the first interface name instead of the anonymous name
Expand Down

0 comments on commit 13c27fc

Please sign in to comment.