Implement KeyManagerLogger (#1386)

This commit is contained in:
Ben Carman 2020-05-28 13:06:50 -05:00 committed by GitHub
parent 44c9228c26
commit b561e47d6b
3 changed files with 29 additions and 2 deletions

View File

@ -418,7 +418,7 @@ lazy val docs = project
lazy val keyManager = project
.in(file("key-manager"))
.settings(CommonSettings.prodSettings: _*)
.dependsOn(core)
.dependsOn(core, dbCommons)
lazy val keyManagerTest = project
.in(file("key-manager-test"))

View File

@ -0,0 +1,26 @@
package org.bitcoins.keymanager
import org.bitcoins.db.{AppLoggers, LoggerConfig}
import org.slf4j.Logger
/** Exposes access to the key manager logger */
private[bitcoins] trait KeyManagerLogger {
private var _logger: Logger = _
protected[bitcoins] def logger(implicit config: LoggerConfig): Logger = {
if (_logger == null) {
_logger = KeyManagerLoggerImpl(config).getLogger
}
_logger
}
}
private[keymanager] case class KeyManagerLoggerImpl(
override val conf: LoggerConfig)
extends AppLoggers {
/**
* @return the generic Key Manager logger (i.e. everything related to secret keys)
*/
def getLogger: Logger =
getLoggerImpl(LoggerKind.KeyHandling)
}

View File

@ -27,7 +27,8 @@ case class BIP39KeyManager(
kmParams: KeyManagerParams,
private val bip39PasswordOpt: Option[String],
creationTime: Instant)
extends KeyManager {
extends KeyManager
with KeyManagerLogger {
private val seed = bip39PasswordOpt match {
case Some(pw) =>
BIP39Seed.fromMnemonic(mnemonic = mnemonic, password = pw)