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

[Simplified] Move pytest-logging functionality to pytest-catchlog #33

Merged
merged 3 commits into from
Aug 7, 2016
Merged

[Simplified] Move pytest-logging functionality to pytest-catchlog #33

merged 3 commits into from
Aug 7, 2016

Conversation

s0undt3ch
Copy link
Contributor

This is a simplified and a more explicit approach to #20

Closes #20.

By default, catchlog will output any logging records with a level higher or equal
to WARNING. In order to actually see these logs in the console you have to disable
pytest output capture by passing ``-s``. The life span of the CLI logging handler
lasts throughout the whole runtests session.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: I'd just say "the whole test session" here, as someone not familiar with pytest internals might not know what you mean with "runtests session".

Alternatively maybe get rid of the whole sentence? This sounds like an implementation detail which is irrelevant to a catchlog user anyways, no?

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'll get rid of the sentence.

@abusalimov
Copy link
Collaborator

What's about adding a --log-level option, which would provide a fallback value for both --log-cli-level and --log-file-level? And making other options behave respectively, i.e. --log-[date-]format to be defaults for --log-{cli,file}-[date-]format.

@s0undt3ch
Copy link
Contributor Author

I didn't initially add --log-level because that would suggest it was targeted to be used with the existing format options(which are to be used in tests, right)?

However, I see no harm, and its actually beneficial, to add the fallback support you suggest.

I'll ping you guys once I'm finished addressing your suggestions...

@s0undt3ch
Copy link
Contributor Author

What I mean with it would suggest is that when users read the whole CLI help message and the available option args, they'd notice the CLI/file distinction and would come to that conclusion?

@s0undt3ch
Copy link
Contributor Author

PR updated.

@abusalimov
Copy link
Collaborator

existing format options(which are to be used in tests, right)?

That's true indeed, though #24 fixes that, i.e. tests will always use the standard formatting, regardless command line options.

@s0undt3ch
Copy link
Contributor Author

Ok! Cool!

@s0undt3ch
Copy link
Contributor Author

So, after #24 is merged, we remove the CLI specific options and use the original ones?

@abusalimov
Copy link
Collaborator

I thought you propose CLI options to be used for live logs, don't you? In this sense, are file options that different from CLI ones to remove the latter, but leave the former?

@s0undt3ch
Copy link
Contributor Author

Yes, CLI options are for live logs, however, I personally, in a CI context, want live logs less verbose and file logs more verbose, hence the separation.

@abusalimov
Copy link
Collaborator

BTW, how is a log file supposed to be used on CI?

@s0undt3ch
Copy link
Contributor Author

We use Jenkins and we store it as an artifact for later inspection if need be.

@s0undt3ch
Copy link
Contributor Author

Is there anything that you'd like me to address on this PR?

@abusalimov
Copy link
Collaborator

Honestly, I doubt the need to add a new set of command line options (--log-cli-...). Not that I'm against that, but adding an option makes the whole thing feel more complex, increases maintenance costs, etc. In other words, I would avoid that unless absolutely necessary.

Is it possible to get along with adding just the --log-level option and maybe reusing the existing -s (i.e. --capture=no)? @The-Compiler @eisensheng your thoughts?

@s0undt3ch
Copy link
Contributor Author

The problem is not the log level option, the problem is the format options which already exist and are not targeted towards CLI usage, they are targeted towards test usage.

When that stops being the case, after your other PR is merged, then we can drop the CLI options and reuse the existing ones.

So, either this goes in with the CLI options to avoid confusion, or, that other PR is merged first and the options are reused fotncli usage, since they won't be targeted for test usage anymore.

Did I make any sense?

@abusalimov
Copy link
Collaborator

Did I make any sense?

Yeah, totally.

I'll try to address remaining issues of that PR to get it merged then.

@s0undt3ch
Copy link
Contributor Author

Awesome!

@s0undt3ch
Copy link
Contributor Author

Rebased to resolve conflicts

@s0undt3ch
Copy link
Contributor Author

Where are we on this PR?

I think I need to rebase... Let me know of anything else required.

@s0undt3ch
Copy link
Contributor Author

I've solved conflicts again. Whats the status of this PR?

@abusalimov
Copy link
Collaborator

I apologize this PR got stalled. The thing is, I have a new job, hence no spare time now, alas. @eisensheng @The-Compiler we need to get over with this feature, I feel ashamed =(

@s0undt3ch
Copy link
Contributor Author

No need to feel ashamed. I know about being busy, why do you think I haven't asked a month or two ago? 😄
Of course I'd like to get this merged, my CI server is running off a branch on my fork with both of my PR's together, but as long as there's still will and you still find it useful, I'll keep updating it until it gets included in the project.

@The-Compiler
Copy link
Collaborator

I agree we somehow need to get all the open stuff in (and then maybe talk about the rename to pytest-logging again) - I'm happy to contribute where I can, but I lack the time to take the lead here, sorry.

I've looked at this PR again, and it seems fine to me. I'm somewhat inclined to just merge it - is there anything still open holding this up?

@s0undt3ch
Copy link
Contributor Author

Nothing holding on my end and about the rename, just say when, although, I'd like to have my other PR merged in too before(which I'll have to rebase once this one is merged).

@eisensheng
Copy link
Owner

I'm also very sorry regarding the current state of this issue. I planned to get back to this issue on this weekend but wasn't able to make it in the end unfortunately.

What's left to do here for me is basically to review the code and the use cases over again, running the test suite, inspecting coverage and (hopefully) approving it. I scheduled the coming saturday for this.

@s0undt3ch
Copy link
Contributor Author

👍

def get_actual_log_level(config, setting_name):
'''
Return the actual logging level
'''
Copy link
Owner

Choose a reason for hiding this comment

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

Can you use double quotes for docstrings, please?

Please look at the bottom of https://www.python.org/dev/peps/pep-0257/#id15 for reference.

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 know that pep, i just choose not to follow for my own projects, I prefer single quotes.
I'll fix it in a bit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we want to follow pep257, that should be """Return the actual logging level.""" - all in one line and with a period 😉

@@ -50,12 +56,60 @@ def pytest_addoption(parser):
dest='log_date_format', default=DEFAULT_LOG_DATE_FORMAT,
help='log date format as used by the logging module.'
)
add_option_ini(
Copy link
Owner

Choose a reason for hiding this comment

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

It's not clear to me why there are two different options that appear to configure the same thing. Can you enlighten me here, please?

Copy link
Collaborator

Choose a reason for hiding this comment

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

There already was some discussion about this.

Copy link
Owner

Choose a reason for hiding this comment

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

Duh! I looked through usage in source but missed that discussion. Sorry!

@eisensheng
Copy link
Owner

eisensheng commented Aug 6, 2016

@s0undt3ch What do you think about adding a test that actually tries to log a message and will appear on stderr accordingly? It might be a bit redundant but that test would be bound to the feature implemented here.

Otherwise it looks good to me apart from that one docstring nitpick and would like to merge it sooner than later.

I'm sorry if my tone was to harsh, it doesn't look to me like that but I was reading some (amusing) torvalds mails before reviewing the branch and I'm afraid his tone slipped in.

@s0undt3ch
Copy link
Contributor Author

No worries about the tones, we all want the same goal, an excellent tool, and sometimes we just see some awkward code which brings out the tone(personal experience), or sometimes the goal is just not properly explained.

I'll add that test later in the evening or as soon as possible, I also want this in sooner than latter.

@s0undt3ch
Copy link
Contributor Author

Single quote replaced with double quotes and tests updated to ensure we actually get the expected logging output in stderr

@eisensheng eisensheng merged commit 84de498 into eisensheng:develop Aug 7, 2016
@The-Compiler
Copy link
Collaborator

Wheee! ✨

@eisensheng
Copy link
Owner

This feature was merged on top of several more changes. It's difficult to draw a line there but the clean up of the entire plugin justifies the next version number to be 2.0.0 but there is still work left to do for the 2.0.0 release. Among that is the pytest-logging rename. This means it will take a little bit longer until this feature hits a published version. Is this okay for anyone interested in this feature or shall I do a 1.x release containing this feature beforehand?

@s0undt3ch s0undt3ch deleted the features/live-logging branch August 7, 2016 18:13
@s0undt3ch
Copy link
Contributor Author

Woohooo!!!!

About waiting for 2.0, no worries on my end, I can keep installing from git.

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.

4 participants