mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 18:02:54 +01:00
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:
parent
51e9796b39
commit
a210c1ec3b
@ -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)
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user