[issue16889] facilitate log output starting at beginning of line

2021-10-22 Thread Irit Katriel


Irit Katriel  added the comment:

Reproduced on 3.11.

--
nosy: +iritkatriel
versions: +Python 3.11 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16889] facilitate log output starting at beginning of line

2013-01-08 Thread Vinay Sajip

Vinay Sajip added the comment:

I agree this is a reasonable expectation, but I've not encountered this problem 
before. Can you provide a short script demonstrating the problem?
Which platform did you encounter these problems on, and what was the logging 
configuration?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16889] facilitate log output starting at beginning of line

2013-01-08 Thread Chris Jerdonek

Chris Jerdonek added the comment:

This can happen with any standard logging configuration when there are writes 
to sys.stderr that don't end with \n.  I'm using Mac OS X 10.7.  A minimal 
script:

import logging, unittest

log = logging.getLogger()

class Test(unittest.TestCase):
def setUp(self):
log.info(setting up)
def test1(self):
pass
def test2(self):
pass

logging.basicConfig(level=logging.INFO)
unittest.main()

Output:

INFO:root:setting up
.INFO:root:setting up
.
--
Ran 2 tests in 0.001s

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16889] facilitate log output starting at beginning of line

2013-01-08 Thread Ezio Melotti

Ezio Melotti added the comment:

Note that for this specific problem you could call unittest.main(verbosity=0).

--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16889] facilitate log output starting at beginning of line

2013-01-08 Thread Vinay Sajip

Vinay Sajip added the comment:

Oh, I see what you mean now. I guess the approach you used is straightforward, 
and perhaps something could be added to test.support. It's only an aesthetic 
thing, though, IIUC.

I normally don't run into this because I log to file when running unit tests, 
or run with -v so that the runner prints complete lines rather than just dots. 
And if you need to test that logging is happening, you can use the TestHandler 
and Matcher classes in test.support.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16889] facilitate log output starting at beginning of line

2013-01-08 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Ezio, the use case is to add to the existing test output additional diagnostic 
logging.  In particular, you might want to run tests even with verbosity=2 in 
addition to the log messages.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16889] facilitate log output starting at beginning of line

2013-01-08 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Yes, it's primarily for easier scanning/reading as well as aesthetic.  With -v 
I get the following output though:

test1 (test_logging.Test) ... INFO:root:setting up
ok
test2 (test_logging.Test) ... INFO:root:setting up
ok

--
Ran 2 tests in 0.000s

At least it's good to know that I wasn't missing anything obvious.  And yes, I 
did read about TestHandler/Matcher (for making assertions about logging) from 
the following informative thread a couple years ago (which I came across when 
filing issue 16884):

http://mail.python.org/pipermail/python-dev/2010-December/106526.html

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16889] facilitate log output starting at beginning of line

2013-01-08 Thread Chris Jerdonek

Chris Jerdonek added the comment:

 and perhaps something could be added to test.support.

Also, just to clarify, I had in mind outside projects and the larger community 
for this request rather than CPython development, so I'm not sure test.support 
would be the right location.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16889] facilitate log output starting at beginning of line

2013-01-08 Thread Vinay Sajip

Vinay Sajip added the comment:

 I had in mind outside projects and the larger community for this request

Fair enough - then the best place for the specialisation of stream and handler 
would seem to be unittest/unittest2. So I'll add Michael Foord to the nosy list.

--
nosy: +michael.foord

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16889] facilitate log output starting at beginning of line

2013-01-07 Thread Chris Jerdonek

New submission from Chris Jerdonek:

In certain situations (e.g. when logging while using unittest), log messages 
can start in the middle of a line, for example:

log: [INFO] foo
..

It was trickier than I thought it needed to be to get log messages to start at 
the beginning of a line, which seems like a reasonable expectation.

It would be good if the logging module (or perhaps unittest for when running 
tests?) provided assistance here, either through documentation or an 
enhancement.

The way I did this was wrap sys.stderr in a class that remembers the last 
written character, pass this to the test runner, and then subclass 
logging.StreamHandler to have emit() check whether a newline was the last 
character.  But perhaps there is a much simpler way.

--
components: Library (Lib)
messages: 179304
nosy: chris.jerdonek, r.david.murray, vinay.sajip
priority: normal
severity: normal
status: open
title: facilitate log output starting at beginning of line
type: enhancement
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com