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
Conversation
@@ -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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
.
@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 |
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. |
6fd4a60
to
dd22021
Compare
let componentDebugLogs = grep "stake-pool-db" allDebugLogs | ||
let networkDebugLogs = grep "network" allDebugLogs | ||
length componentDebugLogs `shouldNotBe` 0 | ||
length networkDebugLogs `shouldBe` 0 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 👍
There was a problem hiding this 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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
bors r+ |
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>
Build failed |
dea37f4
to
d0a92a8
Compare
Oops bors r+ |
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>
Build failed |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 😬 ...
This comes in handy when trying functions in GHCi.
d0a92a8
to
967b995
Compare
bors r+ |
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>
Build failed |
64b6f3f
to
80731aa
Compare
80731aa
to
2281dc5
Compare
Needed to update the launcher tests too, and update some tracer names. bors r+ |
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>
Build succeeded |
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>
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>
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