-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ETCM-107] Backport logging configuration
- Loading branch information
Showing
8 changed files
with
103 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/scala/io/iohk/ethereum/utils/LoadFromApplicationConfiguration.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.iohk.ethereum.utils | ||
|
||
import ch.qos.logback.core.joran.action.Action | ||
import ch.qos.logback.core.joran.spi.InterpretationContext | ||
import com.typesafe.config.ConfigFactory | ||
import org.xml.sax.Attributes | ||
|
||
/** | ||
* Make properties defined in application.conf available to logback | ||
*/ | ||
class LoadFromApplicationConfiguration extends Action { | ||
|
||
val config = ConfigFactory.load | ||
override def begin(ic: InterpretationContext, body: String, attributes: Attributes): Unit = { | ||
ic.addSubstitutionProperty(attributes.getValue("as"), config.getString(attributes.getValue("key"))) | ||
} | ||
override def end(ic: InterpretationContext, body: String): Unit = () | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
package io.iohk.ethereum.utils | ||
|
||
import com.typesafe.scalalogging | ||
import org.slf4j.{LoggerFactory, MDC} | ||
|
||
trait Logger { | ||
import com.typesafe.scalalogging.Logger | ||
val log: scalalogging.Logger = com.typesafe.scalalogging.Logger(LoggerFactory.getLogger(getClass)) | ||
} | ||
|
||
val log = Logger(getClass) | ||
trait LazyLogger { | ||
lazy val log: scalalogging.Logger = com.typesafe.scalalogging.Logger(LoggerFactory.getLogger(getClass)) | ||
} | ||
|
||
trait LoggingContext { | ||
val asParameterMap: Map[String, String] | ||
} | ||
|
||
object LoggingContext { | ||
implicit class ContextLoggerOps[T <: scalalogging.Logger](log: T) { | ||
def withContext(context: LoggingContext)(doLog: T => Unit): Unit = { | ||
context.asParameterMap.foreach { case (key, value) => MDC.put(key, value) } | ||
doLog(log) | ||
MDC.clear() | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
mantis { | ||
logging { | ||
# Flag used to switch logs to the JSON format | ||
# json-output = false | ||
|
||
# Logs directory | ||
# logs-dir = ${mantis.datadir}"/logs" | ||
|
||
# Logs filename | ||
# logs-file = "mantis" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters