Skip Menu |

This queue is for tickets about the Log-Log4perl CPAN distribution.

Report information
The Basics
Id: 76583
Status: open
Priority: 0/
Queue: Log-Log4perl

People
Owner: Nobody in particular
Requestors: cpan698301 [...] mstier.de
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.36
Fixed in: (no value)



Subject: NDC/MDC not very practicial, request for enhancement
There should be a way to use auto-destruction for removing NDC/MDC keys/values. Example: for ( my $i = 0; $i < 10; $i++ ) { my $a = Log::Log4perl::NDC->push(sprintf('i=%d',$i)); ... do something with i ... # automatically remove NDC for i when $a goes out of lexical scope } This comes handy whenever the use case is not so simple. The way it is now, one has to take considerable precaution to avoid spamming the NDC/MDC (ie. remove it before every single return statement or the like).
I use something like: local Log::Log4perl::MDC->get_context->{foo} = 42; For more complex situations I use https://metacpan.org/pod/Scope::Guard