[issue33423] [logging] Improve consistency of logger mechanism.

2018-06-08 Thread Vinay Sajip


Vinay Sajip  added the comment:

You can't make the proposed change (removing call to basicConfig() from 
logging.debug() etc.) without breaking backwards compatibility.

The inconsistency is just a consequence of how you choose to mix and match 
calls to the module-level convenience functions and calls to individual loggers.

I've marked the resolution for this as "not a bug" rather than "wontfix" even 
though the issue is of type "enhancement". That's because I don't think the 
proposed change will be an actual enhancement over the status quo.

--
nosy: +vinay.sajip
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



[issue33423] [logging] Improve consistency of logger mechanism.

2018-05-03 Thread Daehee Kim

Daehee Kim  added the comment:

Oh! Thank you for your kindness. :)

--

___
Python tracker 

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



[issue33423] [logging] Improve consistency of logger mechanism.

2018-05-03 Thread Emanuel Barry

Emanuel Barry  added the comment:

You don't have access to this feature, so I've deleted the message for you :)

--
nosy: +ebarry

___
Python tracker 

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



[issue33423] [logging] Improve consistency of logger mechanism.

2018-05-03 Thread Emanuel Barry

Change by Emanuel Barry :


--
Removed message: https://bugs.python.org/msg316153

___
Python tracker 

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



[issue33423] [logging] Improve consistency of logger mechanism.

2018-05-03 Thread Daehee Kim

Daehee Kim  added the comment:

Please, ignore first one, `msg316153`

It has duplicated message so I rewrote `msg316154`.
I could not find delete or edit messages menu.

--

___
Python tracker 

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



[issue33423] [logging] Improve consistency of logger mechanism.

2018-05-03 Thread Daehee Kim

Daehee Kim  added the comment:

There's a proposal for a fix inconsistency of logger mechanism.
See below.

Example 1.
---
import logging

app_logger = logging.getLogger('app')

app_logger.error('foo')
logging.error('goo')
app_logger.error('foo')
---

result:
foo
ERROR:root:goo
ERROR:app:foo
---
You can see the inconsistency of app_logger results.


Example 2.
---
import logging

stream_handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - 
%(message)s')
stream_handler.setFormatter(formatter)

app_logger: logging.Logger = logging.getLogger('app')
app_logger.setLevel(logging.ERROR)
app_logger.addHandler(stream_handler)


app_logger.critical('foo')
logging.critical('goo')
app_logger.critical('foo')
---

results:
2018-05-04 11:21:15,199 - app - CRITICAL - foo
CRITICAL:root:goo
2018-05-04 11:21:15,200 - app - CRITICAL - foo
CRITICAL:app:foo
---

You can see even inconsistency of app_logger`s outputs count.

So I have some proposals for fix it.

Proposal 1. 
Remove implicit calling `basicConfig`. Then you can get the consistent results.

Result of the example 1.
foo
goo
foo

Result of the example 2.
2018-05-04 11:31:36,069 - app - CRITICAL - foo
goo
2018-05-04 11:31:36,070 - app - CRITICAL - foo

link : 
https://github.com/zsaladin/cpython/commit/c4e789af32da36ba49196fd6be9c070f62346b7a#diff-043d23e54edc5360a7785ae212d1b806


Proposal 2.
Add calling `basicConfig` in `callHandlers` method if the root logger has no 
handler.

Result of the example 1.
ERROR:app:foo
ERROR:root:goo
ERROR:app:foo

Result of the example 2.
2018-05-04 11:36:45,318 - app - CRITICAL - foo
CRITICAL:app:foo
CRITICAL:root:goo
2018-05-04 11:36:45,319 - app - CRITICAL - foo
CRITICAL:app:foo

https://github.com/zsaladin/cpython/commit/fc295b46a4de584dc5c6724125b2c0f8b2694aa6#diff-043d23e54edc5360a7785ae212d1b806


Thank you.

--

___
Python tracker 

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



[issue33423] [logging] Improve consistency of logger mechanism.

2018-05-03 Thread Daehee Kim

New submission from Daehee Kim :

There's a proposal for a fix inconsistency of logger mechanism.
See below.

Example 1.
---
import logging

app_logger = logging.getLogger('app')

app_logger.error('foo')
logging.error('goo')
app_logger.error('foo')
---

result:
foo
ERROR:root:goo
ERROR:app:foo
---
You can see the inconsistency of app_logger results.


Example 2.
---
import logging

stream_handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - 
%(message)s')
stream_handler.setFormatter(formatter)

app_logger: logging.Logger = logging.getLogger('app')
app_logger.setLevel(logging.ERROR)
app_logger.addHandler(stream_handler)


app_logger.critical('foo')
logging.critical('goo')
app_logger.critical('foo')
---

results:
2018-05-04 11:21:15,199 - app - CRITICAL - foo
CRITICAL:root:goo
2018-05-04 11:21:15,200 - app - CRITICAL - foo
CRITICAL:app:foo
---

You can see even inconsistency of app_logger`s outputs count.

So I have some proposals for fix it.

Proposal 1. 
Remove implicit calling `basicConfig`. Then you can get the consistent results.

Result of the example 1.
foo
goo
foo

Result of the example 2.
2018-05-04 11:31:36,069 - app - CRITICAL - foo
goo
2018-05-04 11:31:36,070 - app - CRITICAL - foo

link : 
https://github.com/zsaladin/cpython/commit/c4e789af32da36ba49196fd6be9c070f62346b7a#diff-043d23e54edc5360a7785ae212d1b806


Proposal 2.
Add calling `basicConfig` in `callHandlers` method if the root logger has no 
handler.

Result of the example 1.
foo
goo
foo

Result of the example 2.
2018-05-04 11:31:36,069 - app - CRITICAL - foo
goo
2018-05-04 11:31:36,070 - app - CRITICAL - foo

Result of the example 1.
ERROR:app:foo
ERROR:root:goo
ERROR:app:foo

Result of the example 2.
2018-05-04 11:36:45,318 - app - CRITICAL - foo
CRITICAL:app:foo
CRITICAL:root:goo
2018-05-04 11:36:45,319 - app - CRITICAL - foo
CRITICAL:app:foo

https://github.com/zsaladin/cpython/commit/fc295b46a4de584dc5c6724125b2c0f8b2694aa6#diff-043d23e54edc5360a7785ae212d1b806


Thank you.

--
components: Library (Lib)
messages: 316153
nosy: Daehee Kim
priority: normal
severity: normal
status: open
title: [logging] Improve consistency of logger mechanism.
type: enhancement
versions: Python 3.8

___
Python tracker 

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