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 integration test for CLI tracer options #1257

Merged
merged 5 commits into from Jan 20, 2020
Merged

Conversation

rvl
Copy link
Contributor

@rvl rvl commented Jan 10, 2020

Relates to #1235.

Overview

  • 758ab28
    Add Cardano.Wallet.Logging.stdoutTextTracer
    This comes in handy when trying functions in GHCi.

  • fd4069c
    More logging information at program startup

  • dd22021
    tests: Add integration test for per-component tracing

@rvl rvl self-assigned this Jan 10, 2020
@@ -396,7 +399,7 @@ helperTracingText = unlines $
[ "Additional tracing options:"
, ""
, " --log-level SEVERITY Global minimum severity for a message to be logged."
, " Defaults to \"INFO\" unless otherwise configured."
, " Defaults to \"DEBUG\" unless otherwise configured."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I had to discard this to make other integration tests happy.

@@ -201,7 +206,7 @@ serveWallet
serveWallet
Tracers{..} sTolerance databaseDir hostPref listen lj beforeMainLoop = do
installSignalHandlers (traceWith applicationTracer MsgSigTerm)
traceWith applicationTracer MsgStarting
traceWith applicationTracer $ MsgStarting lj
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lj is here the only one name not self-descriptive (ie., in 207 line)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK fixed - I was trying to stay under 80 columns. 😁

Logging
-------------------------------------------------------------------------------}

data Log
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use ApplicationLog in lib/jormungandr/src/Cardano/Wallet/Jormungandr.hs - maybe we could give some prefix to Log ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to MainLog.

@paweljakubas
Copy link
Contributor

paweljakubas commented Jan 10, 2020

@rvl @KtorZ general question. We have logs datatypes decentralized thought the code. Why we didn't decide to put them in one place - I see this done in cardano-node for logging. Maybe it is better to have them in one place for maintenance (less expansive ripple effect in the codebase when changes happen) or it follows from how monitoring-framework is constructed? Nevertheless, I like that is is scattered in modules that logging concerns (modules take responsibility of their logging)... - it will be easier to decouple them and make them independent what is the path we are taking

@rvl
Copy link
Contributor Author

rvl commented Jan 10, 2020

I asked about this on slack yesterday because I agree with your concern.

My preference would be to have logging types and ToText instances in the same module as the code which uses them, and the other instances (DefineSeverity, ToObject, etc) in an "orphans" module.

@rvl rvl marked this pull request as ready for review January 16, 2020 08:47
let componentDebugLogs = grep "stake-pool-db" allDebugLogs
let networkDebugLogs = grep "network" allDebugLogs
length componentDebugLogs `shouldNotBe` 0
length networkDebugLogs `shouldBe` 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we here are serving with log-level=debug. after 5 seconds we close log handle. and then look into logs "greping" Debug ones. And we do not see neither stake-pool-db nor network related logs. What I do not undestand is why this test is titled Serve debug logs for one component Don't we want to show that something is present here, rather than absent?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, my bad. there is shouldNotBe - yes, that was what I expected to capture!!!! 👍

logged <- T.lines <$> TIO.readFile logs
let countLogs comp = length $
filter (T.isInfixOf $ "cardano-wallet." <> comp) logged
countLogs "network" `shouldBe` 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, after trace-network is off I expect to see no network related logs 👍

Copy link
Contributor

@paweljakubas paweljakubas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! (just slight suggestion to add more tests)

, "--node-port", show (ctx ^. typed @(Port "node"))
, "--random-port"
, "--genesis-block-hash", block0H
, "--log-level", "debug"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is not needed according to defaults - that is my expectation. this is nit-picking, but without it we would show that defaults work properly. Maybe it is good idea (in some next PR) to extend this test in such a way that we play with different combinations of general-log level and component log level and see that defaults are as expected. What happens when component log level is Info and general is Debug, or opposite? Also check two component logs with the same, different log levels... What about showing that when Debug is set then we will not have for sure Info related logs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to change the default global minimum severity back to Info to prevent debug-level MainLog messages from leaking out.

If the global log level is Info then there will be no Debug-level messages whatsoever. There is a check for that.
It the global log level is Debug then there will be Debug, Info, and higher-severity messages.
I added an assertion for showing that when Info is set then we will have for sure Info related logs.
I think that should cover it.

Copy link
Member

@KtorZ KtorZ Jan 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rvl would you mind making "debug" the default again and adding this very comment as a note in place where we set this default to DEBUG ? This is good to know and have in the source code. I didn't realize this when I changed the global default to be INFO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have put that change into #1282. There are are few extra debug severity MainLog messages printed due to this, but I think it's ok.

@rvl
Copy link
Contributor Author

rvl commented Jan 17, 2020

bors r+

iohk-bors bot added a commit that referenced this pull request Jan 17, 2020
1257: Add integration test for CLI tracer options r=rvl a=rvl

Relates to #1235.

# Overview

- 758ab28
  Add Cardano.Wallet.Logging.stdoutTextTracer
  This comes in handy when trying functions in GHCi.

- fd4069c
  More logging information at program startup
  
- dd22021
  tests: Add integration test for per-component tracing



Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jan 17, 2020

Build failed

@rvl
Copy link
Contributor Author

rvl commented Jan 17, 2020

Oops

bors r+

iohk-bors bot added a commit that referenced this pull request Jan 17, 2020
1257: Add integration test for CLI tracer options r=rvl a=rvl

Relates to #1235.

# Overview

- 758ab28
  Add Cardano.Wallet.Logging.stdoutTextTracer
  This comes in handy when trying functions in GHCi.

- fd4069c
  More logging information at program startup
  
- dd22021
  tests: Add integration test for per-component tracing



Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jan 17, 2020

Build failed

Copy link
Member

@KtorZ KtorZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

-- | Creates a tracer that prints any 'ToText' log message. This is useful for
-- debugging functions in the REPL, when you need a 'Tracer' object.
stdoutTextTracer :: (MonadIO m, ToText a) => Tracer m a
stdoutTextTracer = Tracer $ liftIO . T.putStrLn . toText
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

hostPref
listen
backend
beforeMainLoop = do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the kind of moment where I think it's totally fine to not be under 80-lines 😬 ...

@rvl
Copy link
Contributor Author

rvl commented Jan 20, 2020

bors r+

iohk-bors bot added a commit that referenced this pull request Jan 20, 2020
1257: Add integration test for CLI tracer options r=rvl a=rvl

Relates to #1235.

# Overview

- 758ab28
  Add Cardano.Wallet.Logging.stdoutTextTracer
  This comes in handy when trying functions in GHCi.

- fd4069c
  More logging information at program startup
  
- dd22021
  tests: Add integration test for per-component tracing



Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jan 20, 2020

Build failed

@rvl
Copy link
Contributor Author

rvl commented Jan 20, 2020

Needed to update the launcher tests too, and update some tracer names.

bors r+

iohk-bors bot added a commit that referenced this pull request Jan 20, 2020
1257: Add integration test for CLI tracer options r=rvl a=rvl

Relates to #1235.

# Overview

- 758ab28
  Add Cardano.Wallet.Logging.stdoutTextTracer
  This comes in handy when trying functions in GHCi.

- fd4069c
  More logging information at program startup
  
- dd22021
  tests: Add integration test for per-component tracing



Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jan 20, 2020

Build succeeded

@iohk-bors iohk-bors bot merged commit 2281dc5 into master Jan 20, 2020
@rvl rvl deleted the rvl/1235/logging-test branch January 20, 2020 07:29
iohk-bors bot added a commit that referenced this pull request Jan 20, 2020
1282: cardano-wallet-jormungandr: Set default minimum log-level to Debug r=KtorZ a=rvl

Relates to #1235.

# Overview

- Sets default global minimum log level to DEBUG in the CLI.

# Comments

From #1257 (comment)

Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
iohk-bors bot added a commit that referenced this pull request Jan 20, 2020
1282: cardano-wallet-jormungandr: Set default minimum log-level to Debug r=KtorZ a=rvl

Relates to #1235.

# Overview

- Sets default global minimum log level to DEBUG in the CLI.

# Comments

From #1257 (comment)

Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants