All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.digitalasset.ledger.client.binding.log.LogbackThresholdFilterWithExclusion.scala Maven / Gradle / Ivy

There is a newer version: 1.18.2
Show newest version
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package com.daml.ledger.client.binding.log

import ch.qos.logback.classic.filter.ThresholdFilter
import ch.qos.logback.classic.spi.ILoggingEvent
import ch.qos.logback.core.spi.FilterReply

/** Logs at specific level and above, excluded logger logs everything.
  * If you don't have exclusions, use regular ThresholdFilter. Without provided excludeLogger this
  * implementation logs every event with no filtering at all.
  */
class LogbackThresholdFilterWithExclusion extends ThresholdFilter {
  @volatile private var excludeLogger: String = _

  def setExcludeLogger(a: String): Unit = this.excludeLogger = a

  def getExcludeLogger: String = this.excludeLogger

  override def decide(event: ILoggingEvent): FilterReply = {
    if (!this.isStarted) FilterReply.NEUTRAL
    else if (event.getLoggerName.startsWith(excludeLogger)) FilterReply.NEUTRAL
    else super.decide(event)
  }

  override def start(): Unit = {
    if (this.excludeLogger != null) {
      super.start()
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy