09.10.19 14:02, Chris Angelico пише:
The decorator has full access to the function object, including a
reference to that function's module globals.
def trace(func):
log = func.__globals__["log"]
... proceed as before
As long as you can depend on "log" always being a module-level
(glob
On 9/10/19 13:02, Chris Angelico wrote:
> On Wed, Oct 9, 2019 at 9:53 PM Antoon Pardon wrote:
>> I have some logging utilities so that when I write library code, I just use
>> the following.
>>
>> from logutil import Logger
>>
>> log = Logger(__name__)
> Are you always absolutely consistent with
Antoon Pardon wrote:
> I have some logging utilities so that when I write library code, I just
> use the following.
>
> from logutil import Logger
>
> log = Logger(__name__)
If logutil is under your control you can make log a callable object with a
tracing method:
[logutil.py]
class Logger:
On Wed, Oct 9, 2019 at 9:53 PM Antoon Pardon wrote:
>
> I have some logging utilities so that when I write library code, I just use
> the following.
>
> from logutil import Logger
>
> log = Logger(__name__)
Are you always absolutely consistent with this? Do you always have it
as a module-level v