Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable logging to data directory #640

Merged

Conversation

torkelrogstad
Copy link
Contributor

@torkelrogstad torkelrogstad commented Jul 17, 2019

Closes #588

In this PR we add the ability for the node, chain
and wallet projects (+ the server) to log to the users
data directory instead of whatever directory the
binaries was launched from. This is inherently a bit
more complicated than our previous setup, because
we need to read the user directory before we can create
loggers. As a result of this, some files/methods were
moved around, so the relevant app config could be
found in scope.

Discussion item:

Right now we log in a similar way to how we already do it, by passing in the name of the file (instead of the class, but leads to almost identical behavior), and then constructing a logger with that name. This is why sourcecode (from Li Haoyi) is added as a dependency. Should we instead move to a category based system, where we log with a predefined set of categories? This is how both Bitcoin Core and Lnd handles it. Categories could be things such as chainsync, P2P messages, transaction creation, address derivation, peer handling, etc. IMO this is a better solution, primarily because when we have a predefined number of loggers its easy to expose options in reference.conf for fine-tuning behavior of each logger. I.e. the user could set P2P messages to be logged at DEBUG, but turn off chain sync logs.

TODO:

  • Make console/file logging something the user can turn on/off
  • Make specific loggers tunable wrt. levels
  • Add doc on logging for dev purposes

UPDATE:

Added several logging categories, as well as options for tuning logging levels and file and console logs on/off.

@torkelrogstad torkelrogstad added chain work on the chain project node work for the node project wallet work for the wallet project labels Jul 17, 2019
@torkelrogstad torkelrogstad changed the title WIP: Add logging to data directory Add configurable logging to data directory Jul 18, 2019
@torkelrogstad torkelrogstad force-pushed the 2019-07-17-datadir-logging branch 2 times, most recently from c5bb910 to 85aee98 Compare July 31, 2019 10:48
@Christewart
Copy link
Contributor

Christewart commented Jul 31, 2019

This fails to compile on 2.11

https://travis-ci.org/bitcoin-s/bitcoin-s/jobs/565913446#L621

@Christewart
Copy link
Contributor

Christewart commented Jul 31, 2019

Tests do not pass for me locally either

[info] ChainAppConfigTest:
[info] - must be overridable *** FAILED ***
[info]   RegTest did not equal TestNet3 (ChainAppConfigTest.scala:21)
[info]   org.scalatest.exceptions.TestFailedException:
[info]   at org.scalatest.Assertions.newAssertionFailedException(Assertions.scala:530)
[info]   at org.scalatest.Assertions.newAssertionFailedException$(Assertions.scala:529)
[info]   at org.scalatest.FlatSpec.newAssertionFailedException(FlatSpec.scala:1685)
[info]   at org.scalatest.Assertions$AssertionsHelper.macroAssert(Assertions.scala:503)
[info]   at org.bitcoins.chain.ChainAppConfigTest.$anonfun$new$1(ChainAppConfigTest.scala:21)
[info]   at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
[info]   at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
[info]   at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)

In this commit we add the ability for the node, chain
and wallet projects (+ the server) to log to the users
data directory instead of whatever directory the
binaries was launched from. This is inherently a bit
more complicated than our previous setup, because
we need to read the user directory before we can create
loggers. As a result of this, some files/methods were
moved around, so the relevant app config could be
found in scope.

We also  introduce several logging categories that can be
tuned individually through user configuration. These logggers
are exposed both as traits that give a field `logger`, or
as methods that return the required logger.
In this commit we add support for AppConfig to pick up
the data directory configuration file. We also add
a section to the contributing guide on how to tune
logging levels.
@torkelrogstad
Copy link
Contributor Author

The error you're having is not reproducing locally for me, nor on CI. Are you still seeing them, @Christewart ?

@torkelrogstad
Copy link
Contributor Author

I pushed a new commit that changes our app configs to explictly take in the data directory as a parameter, instead of magically resolving it. This also closes #588

@Christewart Christewart merged commit 31642af into bitcoin-s:master Aug 1, 2019
@Christewart Christewart mentioned this pull request Aug 13, 2019
Christewart pushed a commit that referenced this pull request May 1, 2021
* Add logging to data directory

In this commit we add the ability for the node, chain
and wallet projects (+ the server) to log to the users
data directory instead of whatever directory the
binaries was launched from. This is inherently a bit
more complicated than our previous setup, because
we need to read the user directory before we can create
loggers. As a result of this, some files/methods were
moved around, so the relevant app config could be
found in scope.

We also  introduce several logging categories that can be
tuned individually through user configuration. These logggers
are exposed both as traits that give a field `logger`, or
as methods that return the required logger.

* Add datadir configuration to AppConfig

In this commit we add support for AppConfig to pick up
the data directory configuration file. We also add
a section to the contributing guide on how to tune
logging levels.

* Pass data directories explicitly for configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chain work on the chain project node work for the node project wallet work for the wallet project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change syntax for creating app configs
3 participants