2021 01 09 issue 2496 (#2500)

* WIP: Get something working that isn't network specific

Start putting things back in place

Add comment

Revert logback file

Remove BitcoinSLogger object

* fix unit test

* Network specific log location

Co-authored-by: benthecarman <benthecarman@live.com>
This commit is contained in:
Chris Stewart 2021-01-11 16:48:49 -06:00 committed by GitHub
parent 51e9796b39
commit a210c1ec3b
3 changed files with 26 additions and 12 deletions

View File

@ -62,7 +62,7 @@ trait BitcoinSRunner extends BitcoinSLogger {
argsWithIndex.find(_._1.toLowerCase == "--conf").map(_._2)
}
val datadirConfig: Config =
lazy val datadirConfig: Config =
ConfigFactory.parseString(
s"bitcoin-s.datadir = ${safePathToString(datadirPath)}")
@ -97,9 +97,21 @@ trait BitcoinSRunner extends BitcoinSLogger {
val networkDatadir: Path = {
val networkStr: String =
baseConfig.getString("bitcoin-s.network")
val network: BitcoinNetwork =
BitcoinNetworks.fromString(networkStr)
lazy val lastDirname = network match {
val network: BitcoinNetwork = networkStr.toLowerCase match {
case "mainnet" => MainNet
case "main" => MainNet
case "testnet3" => TestNet3
case "testnet" => TestNet3
case "test" => TestNet3
case "regtest" => RegTest
case "signet" => SigNet
case "sig" => SigNet
case _: String =>
throw new IllegalArgumentException(s"Invalid network $networkStr")
}
val lastDirname = network match {
case MainNet => "mainnet"
case TestNet3 => "testnet3"
case RegTest => "regtest"
@ -108,12 +120,16 @@ trait BitcoinSRunner extends BitcoinSLogger {
datadir.resolve(lastDirname)
}
logger.info(s"version=${EnvUtil.getVersion}")
// Properly set log location
//We need to set the system property before any logger instances
//are in instantiated. If we don't do this, we will not log to
//the correct location
//see: https://github.com/bitcoin-s/bitcoin-s/issues/2496
System.setProperty("bitcoins.log.location",
networkDatadir.toAbsolutePath.toString)
logger.info(s"version=${EnvUtil.getVersion}")
logger.info(s"networkDatadir=${networkDatadir.toAbsolutePath.toString}")
val runner = startup
runner.failed.foreach { err =>
logger.error(s"Failed to startup server!", err)

View File

@ -3,7 +3,6 @@ package org.bitcoins.server
import akka.actor.ActorSystem
import akka.dispatch.Dispatchers
import akka.http.scaladsl.Http
import grizzled.slf4j.Logging
import org.bitcoins.chain.blockchain.ChainHandler
import org.bitcoins.chain.config.ChainAppConfig
import org.bitcoins.chain.models._
@ -26,8 +25,7 @@ import org.bitcoins.wallet.config.WalletAppConfig
import scala.concurrent.{ExecutionContext, Future, Promise}
class BitcoinSServerMain(override val args: Array[String])
extends BitcoinSRunner
with Logging {
extends BitcoinSRunner {
override val actorSystemName = "bitcoin-s-server"

View File

@ -122,8 +122,8 @@ abstract class AppConfig extends StartStopAsync[Unit] with BitcoinSLogger {
protected lazy val config: Config = {
val finalConfig = AppConfig.getBaseConfig(baseDatadir, configOverrides)
logger.debug(s"Resolved bitcoin-s config:")
logger.debug(finalConfig.asReadableJson)
logger.trace(s"Resolved bitcoin-s config:")
logger.trace(finalConfig.asReadableJson)
val resolved = {
ConfigFactory