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

Request for --logging-level=INFO to limit logging capture #21

Open
jpellerin opened this issue Dec 14, 2011 · 11 comments · Fixed by #493
Open

Request for --logging-level=INFO to limit logging capture #21

jpellerin opened this issue Dec 14, 2011 · 11 comments · Fixed by #493
Assignees

Comments

@jpellerin
Copy link
Member

What steps will reproduce the problem?

  1. create an app like a pylons app or something that logs a lot of messages
  2. run nosetests

What is the expected output? What do you see instead?

As expected, logging messages at all levels are captured including DEBUG.
But it would be nice if one could limit the level like this:

nosetests --logging-level=INFO

Then only messages at that level or above would be captured. What should
happen to the messages beneath that level? They should probably be
swallowed I think. The problem to solve is that the nose captured output
can grow enormously with the DEBUG level and can become hard to read.

What version of the product are you using? On what operating system?

0.11

Please provide any additional information below.

http://somethingaboutorange.com/mrl/projects/nose/0.11.1/plugins/logcapture.html

Google Code Info:
Issue #: 268
Author: kumar.mcmillan
Created On: 2009-05-21T15:41:17.000Z
Closed On:

@ghost ghost assigned jpellerin Dec 14, 2011
@jpellerin
Copy link
Member Author

I have the same problem using nosetests fenics; debug level logging prints and enormous amount of internal data structures etc. For now just using --nologcapture, but would be nice to be able to change the level rather than just disabling.

Google Code Info:
Author: [email protected]
Created On: 2011-06-20T16:19:07.000Z

@jpellerin
Copy link
Member Author

I mean nosetests with fenics based code :)

Google Code Info:
Author: [email protected]
Created On: 2011-06-20T16:19:45.000Z

@jpellerin
Copy link
Member Author

Ran into the same issue. Here's a diff of a solution.

diff -r 43d9088a4553 nose/plugins/logcapture.py
--- a/nose/plugins/logcapture.py Fri Aug 05 10:26:21 2011 -0500
+++ b/nose/plugins/logcapture.py Wed Aug 31 14:24:29 2011 -0400
@@ -149,6 +149,10 @@
"--logging-clear-handlers", action="store_true",
default=False, dest="logcapture_clear",
help="Clear all other logging handlers")

  •    parser.add_option(
    
  •        "--logging-level", action="store",
    
  •        default='NOTSET', dest="logcapture_level",
    
  •        help="Set the log level to capture")
    

    def configure(self, options, conf):
    """Configure plugin.
    @@ -161,6 +165,7 @@
    self.logformat = options.logcapture_format
    self.logdatefmt = options.logcapture_datefmt
    self.clear = options.logcapture_clear

  •    self.loglevel = options.logcapture_level
     if options.logcapture_filters:
         self.filters = options.logcapture_filters.split(',')
    

@@ -186,7 +191,7 @@
root_logger.handlers.remove(handler)
root_logger.addHandler(self.handler)
# to make sure everything gets captured

  •    root_logger.setLevel(logging.NOTSET)
    
  •    root_logger.setLevel(getattr(logging,self.loglevel))
    

    def begin(self):
    """Set up logging handler before test run begins.

Google Code Info:
Author: [email protected]
Created On: 2011-08-31T18:27:24.000Z

@jpellerin
Copy link
Member Author

Added logcapture.py

Google Code Info:
Author: [email protected]
Created On: 2011-08-31T18:33:17.000Z

@jpellerin
Copy link
Member Author

Awesome, thanks for starting a patch! It looks like it just needs a translation between readable logging levels and numeric levels. As is, I don't see how it would work because the value of logging.NOTSET is actually 0 not 'NOTSET'.

Google Code Info:
Author: kumar.mcmillan
Created On: 2011-09-01T16:17:58.000Z

@jpellerin
Copy link
Member Author

No worries. I think getattr(logging, self.loglevel) does what we want here. Right?

@@ -186,7 +191,7 @@
root_logger.handlers.remove(handler)
root_logger.addHandler(self.handler)
# to make sure everything gets captured

  •    root_logger.setLevel(logging.NOTSET)
    
  •    root_logger.setLevel(getattr(logging,self.loglevel))
    

Google Code Info:
Author: [email protected]
Created On: 2011-09-27T23:13:48.000Z

@jpellerin
Copy link
Member Author

Can we please add this patch? So annoying with out it.

Google Code Info:
Author: [email protected]
Created On: 2011-11-07T18:09:10.000Z

@jpellerin
Copy link
Member Author

could you add a unit or functional test for this? thanks

Google Code Info:
Author: [email protected]
Created On: 2011-11-08T21:05:44.000Z

@jpellerin
Copy link
Member Author

http://code.google.com/p/python-nose/issues/detail?id=268 has an incomplete patch (tests needed)

@jayvdb
Copy link

jayvdb commented Dec 12, 2014

Should this issue be closed now it is available as part of the logcapture plugin?

@diabloneo
Copy link

I verified this feature on nose 1.3.7. But you should specify -s option before --logging-level=INFO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants