[issue33057] logging.Manager.logRecordFactory is never used

2018-06-05 Thread Vinay Sajip


Vinay Sajip  added the comment:

I'm closing this, please reopen if you have more information which might change 
my view.

--
resolution:  -> not a bug
stage: patch review -> 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



[issue33057] logging.Manager.logRecordFactory is never used

2018-03-17 Thread Vinay Sajip

Vinay Sajip  added the comment:

> However, it seems that someone already thought about it before and started 
> implementing this mechanism

That someone was me. I decided that a single module-level factory was good 
enough but failed to delete the things you noticed.

>From what you've said, it looks more and more like an XY problem and I would 
>guess that your requirement can be solved by either using a custom message 
>object or some other method already supported by existing mechanisms.

--

___
Python tracker 

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



[issue33057] logging.Manager.logRecordFactory is never used

2018-03-16 Thread Ben Feinstein

Ben Feinstein  added the comment:

General loggers are used in the standard way (message, args, etc), but data
loggers are used for different types of data. Instead of message, they
receive the experiment results (dict/list/np.array/binary data) and their
`formatMessage()` method should be modified in order to account for the
changed data-type.

This might indeed be an XY problem on my side. However, it seems that
someone already thought about it before and started implementing this
mechanism (`Manager.setLogRecordFactory()`), but didn't finish. That's why
I suggested this modification.

On Thu, Mar 15, 2018 at 4:21 PM Vinay Sajip  wrote:

>
> Vinay Sajip  added the comment:
>
> >  I have two types of loggers, one for experiment results ("data") and
> another for general information
>
> In what way is the behaviour of the two types of logger different? I'm
> concerned that this might be an XY problem ...
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue33057] logging.Manager.logRecordFactory is never used

2018-03-15 Thread Vinay Sajip

Vinay Sajip  added the comment:

>  I have two types of loggers, one for experiment results ("data") and another 
> for general information

In what way is the behaviour of the two types of logger different? I'm 
concerned that this might be an XY problem ...

--

___
Python tracker 

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



[issue33057] logging.Manager.logRecordFactory is never used

2018-03-15 Thread Ben Feinstein

Ben Feinstein  added the comment:

I use the logging module to log records of lab experiments. I have two
types of loggers, one for experiment results ("data") and another for
general information. I think that having a different managers for data
loggers is the easiest way to do it.

On Thu, Mar 15, 2018, 07:25 Vinay Sajip  wrote:

>
> Vinay Sajip  added the comment:
>
> The logRecordFactory attribute was added but never used and is part of an
> internal API (the Manager isn't documented, on purpose). Why do you need a
> manager-specific factory?
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue33057] logging.Manager.logRecordFactory is never used

2018-03-14 Thread Vinay Sajip

Vinay Sajip  added the comment:

The logRecordFactory attribute was added but never used and is part of an 
internal API (the Manager isn't documented, on purpose). Why do you need a 
manager-specific factory?

--

___
Python tracker 

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



[issue33057] logging.Manager.logRecordFactory is never used

2018-03-14 Thread Ben Feinstein

Ben Feinstein  added the comment:

Here is a code that demonstrate the bug:

```python
import logging

class LogRecordTypeFilter(logging.Filter):
def __init__(self, cls):
self.cls = cls

def filter(self, record):
t = type(record)
if t is not self.cls:
msg = 'Unexpected LogRecord type %s, expected %s' % (t, self.cls)
raise TypeError(msg)
return True

class MyLogRecord(logging.LogRecord):
pass

manager = logging.Manager(None)
manager.setLogRecordFactory(MyLogRecord)
logger = manager.getLogger('some_logger')
logger.addFilter(LogRecordTypeFilter(MyLogRecord))

try:
logger.error('bpo-33057')
except TypeError as e:
print(e)  # output: Unexpected LogRecord type , 
expected 
```

--

___
Python tracker 

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



[issue33057] logging.Manager.logRecordFactory is never used

2018-03-12 Thread Ben Feinstein

Change by Ben Feinstein :


Removed file: https://bugs.python.org/file47478/issue_logRecordFactory.py

___
Python tracker 

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



[issue33057] logging.Manager.logRecordFactory is never used

2018-03-12 Thread Ben Feinstein

Change by Ben Feinstein :


--
keywords: +patch
pull_requests: +5848
stage:  -> patch review

___
Python tracker 

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



[issue33057] logging.Manager.logRecordFactory is never used

2018-03-12 Thread Ben Feinstein

New submission from Ben Feinstein :

In logging.Manager, the logRecordFactory attribute is never used.

One would expect that makeRecord() (in logging.Logger) would generate a record 
using its manager's logRecordFactory, or fallback to the global 
_logRecordFactory (if has no manager, or manager.logRecordFactory is None), but 
the latter is used exclusively.

--
components: Library (Lib)
files: issue_logRecordFactory.py
messages: 313662
nosy: feinsteinben, vinay.sajip
priority: normal
severity: normal
status: open
title: logging.Manager.logRecordFactory is never used
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file47478/issue_logRecordFactory.py

___
Python tracker 

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