[issue34107] root.warning('msg') output format modified by logging.warning('msg')

2018-07-13 Thread Michael Kearney


Michael Kearney  added the comment:

Thanks for the clarification and doc pointers. I saw "lastResort" attribute in 
the code 
but had not fully understood what was going on. I am not certain I really do 
now, but that's ok. That's why we read docs, read and write
code. Eventually it starts making sense.
It appears that there is history to contend with or complications provoked by 
threads. 

I had not yet read the lastResort discussion in the documentation. That's deep 
in the 
advanced tutorial, I was getting tripped up by simple examples that I concocted 
from 
very simple cases, which can be on the fringes of actual usage. I wonder why 
"lastResort" differs from the built-in default. 

I was playing with basicConfig because I wanted to experiment with formatting 
and level,
and I managed to generate messages that seemed unrelated to formating I had 
specified.


For now it appears that after
import logging

I can add 
logging.warning('')

and achieve what I want. I get the default format where I expect rather than 
lastResort format.

I prefer the default format that I get from the internal call to basicConfig.
I can imagine the there will be a situation where I want the even simpler
"last resort format".

--

___
Python tracker 

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



[issue34107] root.warning('msg') output format modified by logging.warning('msg')

2018-07-13 Thread Vinay Sajip


Vinay Sajip  added the comment:

This behaviour is as expected. If no handlers are configured for logging, an 
internal "handler of last resort" is used, with just the message output. See:

https://docs.python.org/3/howto/logging.html#what-happens-if-no-configuration-is-provided

If you call logging.warning(...), and if no handlers are configured, then 
basicConfig() is internally called to set up a handler with a basic format 
string. See:

https://docs.python.org/3/library/logging.html#logging.log

So, what you've described is as it should be.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue34107] root.warning('msg') output format modified by logging.warning('msg')

2018-07-13 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue34107] root.warning('msg') output format modified by logging.warning('msg')

2018-07-12 Thread Ned Deily


Change by Ned Deily :


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue34107] root.warning('msg') output format modified by logging.warning('msg')

2018-07-12 Thread Michael Kearney


New submission from Michael Kearney :

0 >>> import logging
1 >>> root=logging.getLogger(name='root')
2 >>> root.warning('msg')
3 msg   <- Compare this line
4 >>> logging.warning('msg')
5 WARNING:root:msg
6 >>> root.warning('msg')
7 WARNING:root:msg  <-- with this line

Specifically, I was surprised to see
   line 7 response to line 6
given
   line 3 response to line 2

logger methods log(),critical(),error(),info() act the same way.

A workaround from issue 33897 fixes things
   logging.basicConfig(level=logging.DEBUG, force=True)

I discovered this when exploring "logging" module defaults, It is the sort of 
thing someone new to the module might encounter. I did.

Slightly more comprehensive unittest example attached.

This may be my first real submission. Feedback appreciated

--
files: logTest.py
messages: 321582
nosy: Michael Kearney
priority: normal
severity: normal
status: open
title: root.warning('msg') output format  modified by logging.warning('msg')
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file47686/logTest.py

___
Python tracker 

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