Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

airframe-log: Fixes #2777 Use the default System.err for supporting sbtn #2780

Merged
merged 1 commit into from
Mar 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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