Skip to content

Commit

Permalink
log (fix #3728): Respect the log level of the target logger in Scala …
Browse files Browse the repository at this point in the history
…Native (#3750)
  • Loading branch information
xerial authored Dec 5, 2024
1 parent 3d26ba3 commit 31f5219
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions airframe-log/.native/src/main/scala/java/util/logging/Logger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@ class Logger(parent: Option[Logger], name: String) {
def log(record: LogRecord): Unit = {
if (isLoggable(record.getLevel())) {
if (record.getLoggerName() == null) record.setLoggerName(name)
if (parent.nonEmpty && useParentHandlers) {
getParent().log(record)
} else {
handlers.foreach { h => h.publish(record) }
}
publish(record)
}
}

/**
* Publish the log record, regardless of the log level
* @param record
*/
private[logging] def publish(record: LogRecord): Unit = {
if (useParentHandlers && parent.nonEmpty) {
parent.get.publish(record)
} else {
handlers.foreach { h => h.publish(record) }
}
}

Expand Down

0 comments on commit 31f5219

Please sign in to comment.