-
Notifications
You must be signed in to change notification settings - Fork 4
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
Do not show logs for failed tests by default #124
Open
lorenyu
wants to merge
14
commits into
main
Choose a base branch
from
lorenyu/testlogcapture
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3b4b441
Don't kill all processes when testing os.kill
lorenyu ae18998
Use cat instead of ls to avoid race condition
lorenyu 3eec7e2
Isolate audit tests from rest of tests
lorenyu da712bc
Set db environment variables
lorenyu dd085c6
Add autouse fixture to load local env vars instead
lorenyu bdca593
Merge branch 'main' into lorenyu/testonhost
lorenyu 2e3d39a
Remove obsolete comment
lorenyu 9d3a8c3
Merge branch 'lorenyu/testonhost' of github.com:navapbc/template-appl…
lorenyu 49abc63
Revert var name
lorenyu 200d2ad
Turn off log capture for failed tests by default
lorenyu 9b37c07
Update comment explaining log capture
lorenyu 6edbc27
Merge branch 'main' into lorenyu/testlogcapture
lorenyu 19b4eeb
Add link to docs
lorenyu 103cff7
Merge branch 'lorenyu/testlogcapture' of github.com:navapbc/template-…
lorenyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Might be good to have a quick sync chat on this. While I do want to keep my setup working, I don't want to dictate the implementation so much so for just myself.
Ideally the default would be roughly the same verbosity as it was before the changes to avoid drowing out the test output, but configurable enough for when you do want the full logs.
I did like your idea about a separate
.env
file for an individual developer, but what would be the best way to make it clear that exists?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.
Sure happy to chat about it. I'll look for some time.
If I understand correctly, before the changes either the console handler we defined would be attached to the root logger, or the caplog handler would be attached (if the developer included the logging_fix fixture which turned off the console handler), but not both.
the console handler verbosity can be controlled via LOG_LEVEL, which could either be in local.env or a separate test.env file if we go that route. the caplog verbosity can be controlled by
caplog.setLevel(
.also by default, neither the logs that get printed to stdout stream from console handler nor the logs captured by caplog get shown to the user unless a test fails, and at that point both sets of logs get printed out.
so maybe we can chat about what the ideal would be in each / all of these scenarios, and how it could potentially be flexible to individual developer preferences.
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 think I've got an idea, not sure the best way to configure it, but rather than messing with log levels, what about the stream handler itself?
Right now, we configure the stream handler in logging/config.py as
console_handler = logging.StreamHandler(sys.stdout)
, but what if that was overridable in some way?If we make a real simple stream ourselves:
and then do
logging.StreamHandler(NullStream())
- we get no logs.I'm not sure how we would want to configure this though. I think this might be best handled by the user-specific env file we've thought about, unless you've got another idea?
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 seems reasonable. But it seems like it has the same effect as changing the log level while requiring more code?
I'm imagining it'd be the difference in local.env of
log_handler=console
vslog_level=CRITICAL
orlog_level=WARNING
Do you think the question boils down to how we can have user-specific env files? If so, I think we can rename
local.env
to.env
, remove it from source control, provide anexample.env
, and add something along the lines ofcp local.env .env if .env doesn't already exist
tomake setup-local
. i think we can do that usingMakefile
's built in method of detecting whether a target already exists i.e.