feat: print logs of failed test when error is thrown in bouncer test.#6071
feat: print logs of failed test when error is thrown in bouncer test.#6071
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
3494d9d to
86b3f26
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
bouncer/shared/utils/logger.ts
Outdated
| const testLogFile = getTestLogFile(this); | ||
| if (!existsSync(dirname(testLogFile))) { | ||
| mkdirSync(dirname(testLogFile), { recursive: true }); | ||
| } |
There was a problem hiding this comment.
I was looking in this file and saw:
pino.multistream([
{ stream: prettyConsoleTransport, level: process.env.BOUNCER_LOG_LEVEL ?? 'info' },
{ stream: logFileDestination, level: 'trace' },
]),
Maybe there's a way to do what we want using pino? Something like this:
pino.multistream([
{ stream: prettyConsoleTransport, level: process.env.BOUNCER_LOG_LEVEL ?? 'info' },
{ stream: globalLogFileDestination, level: 'debug' },
{ stream: testLogFileDestination, level: 'trace' },
]),
Basically, I wonder if we need to define a shared 'globalLogger' at all - maybe we can just instantiate a logger for each test that logs to some common 'globalDestination' and to a test-specific file...
There was a problem hiding this comment.
Unfortunately I don't see an obvious way to do that. Here's someone who tried to do something similar, and his solution doesn't really sound easier in terms of implementation complexity. pinojs/pino#2104
EDIT:
Basically, I wonder if we need to define a shared 'globalLogger' at all - maybe we can just instantiate a logger for each test that logs to some common 'globalDestination' and to a test-specific file...
Hmm, I see what you mean. I'll think about it... But I think it will again involve more changes?
There was a problem hiding this comment.
As discussed, let's avoid going down the pino rabbit hole and leave it as is.
37160dc to
bed494c
Compare
…#6071) * feat: print logs of failed test when error is thrown in bouncer test. * refactor: use files instead of local storage to store test logs. * refactor: use files instead of storage to log test-specific logs to. * fix: log in observe event only every 5 blocks. * chore: don't write test-logs for 'trace' level. * fix: handle test timeout ourselves.
…#6071) * feat: print logs of failed test when error is thrown in bouncer test. * refactor: use files instead of local storage to store test logs. * refactor: use files instead of storage to log test-specific logs to. * fix: log in observe event only every 5 blocks. * chore: don't write test-logs for 'trace' level. * fix: handle test timeout ourselves.
Pull Request
Stores all logs of a logger in a custom
logStorageattribute. If a test fails, we can print out all logs that this logger accumulated, giving more context into the reason for failure.Example output: