[issue23597] Allow easy display of local variables in log messages?

2021-10-29 Thread Martin


Martin  added the comment:

In this pull request[1] I introduced a `format_locals` which can be provided to 
customize the serialization of the local variables of each frame. This could be 
used to filter out variables with certain names, for example. In this context, 
you could use a certain naming convention for variables with sensitive 
information and filter them out:

def _format_locals(filename, lineno, name, locals):
return {k: repr(v) for k,v in locals.items() if not 
k.endsswith("_sensitive")}

traceback.TracebackException.from_exception(e, capture_locals=True, 
format_locals=format_locals).format()

(This should be exactly what Robert was suggesting.)


[1] https://github.com/python/cpython/pull/29299

--
keywords: +patch
message_count: 3.0 -> 4.0
nosy: +moi90
nosy_count: 4.0 -> 5.0
pull_requests: +27572
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29299

___
Python tracker 

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



[issue23597] Allow easy display of local variables in log messages?

2021-10-22 Thread Irit Katriel


Irit Katriel  added the comment:

See also 43656.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue23597] Allow easy display of local variables in log messages?

2021-10-22 Thread Irit Katriel


Change by Irit Katriel :


--
type:  -> enhancement
versions: +Python 3.11 -Python 3.5

___
Python tracker 

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



[issue23597] Allow easy display of local variables in log messages?

2015-08-25 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

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



[issue23597] Allow easy display of local variables in log messages?

2015-03-05 Thread Nick Coghlan

New submission from Nick Coghlan:

Issue #22936 added support for easily displaying local variables in tracebacks 
to the unittest and traceback modules.

Would it be worth also making this capability readily available in the logging 
APIs that display traceback messages?

The main argument against it is that automatically logging local variables in 
tracebacks is a *really* good way to introduce sensitive information leaks into 
your log messages. Safe repr type objects (which automatically mask sensitive 
details in __repr__()) can mitigate this, but we don't provide such an object 
in the standard library (not even for bytes, bytearray or str, which are the 
typical containers for potentially sensitive data like passwords).

--
messages: 237319
nosy: ncoghlan
priority: normal
severity: normal
status: open
title: Allow easy display of local variables in log messages?
versions: Python 3.5

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



[issue23597] Allow easy display of local variables in log messages?

2015-03-05 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


--
dependencies: +traceback module has no way to show locals

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



[issue23597] Allow easy display of local variables in log messages?

2015-03-05 Thread Robert Collins

Robert Collins added the comment:

Yes, for debugging etc this can be very useful. I suggest further extending the 
new traceback interface to allow a filtering/transform hook of some sort, to 
allow folk more granular control than just repr overloading.

--
nosy: +rbcollins

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