Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Get stricter with use warnings FATAL => 'all';

by mje (Curate)
on Oct 12, 2011 at 18:56 UTC ( [id://931066]=note: print w/replies, xml ) Need Help??


in reply to Get stricter with use warnings FATAL => 'all';

As often is the case there are two sides to each argument. This would not work for some code I use as warnings are often issued with warn() or Log::Log4perl::logwarn as a warning (something you should take notice of but it is not necessarily a code bug). If I just indiscriminately set warnigs are promoted to fatal a lot of code would stop working. This is partly where the Perl system of warnings breaks down. Warnings issued by Perl itself are probably worth knowing (and perhaps worth promoting to fatal so you can actually add code to cope with it) but application code can also call warn and in this case it probably means - take note - something to be aware of - but not necessarily fatal.

  • Comment on Re: Get stricter with use warnings FATAL => 'all';

Replies are listed 'Best First'.
Re^2: Get stricter with use warnings FATAL => 'all';
by toolic (Bishop) on Oct 12, 2011 at 19:18 UTC
    mje,

    Thank you for the feedback.

    This would not work for some code I use as warnings are often issued with warn()
    If you are referring to warn, then there is no problem. use warnings FATAL => 'all'; will not cause a warn to die, as shown by this example:
    use warnings FATAL => 'all'; use strict; warn "foo\n"; warn "bar\n"; __END__ foo bar

    I have never used Log::Log4perl (or any similar logging modules), but I would be surprised if it promoted its warnings to fatals. When I get a chance, I will try to figure out how to use the Log module to confirm your assertion. Feel free to post a small example which proves this. Thanks for pointing this out.

    UPDATE: Here is my 1st attempt at using Log::Log4perl. In this mode, the warning is not promoted to a fatal. I have more to learn about the module.

    use strict; use warnings FATAL => 'all'; use Log::Log4perl qw(:easy); Log::Log4perl->easy_init($DEBUG); WARN("foo"); DEBUG "A low-level message"; ERROR "Won't make it until level gets increased to ERROR"; WARN('bar'); __END__ 2011/10/12 21:05:08 foo 2011/10/12 21:05:08 A low-level message 2011/10/12 21:05:08 Won't make it until level gets increased to ERROR 2011/10/12 21:05:08 bar
    I also tried the Core Log::Message module, and I did not observe warnings turning into fatals there either.

      toolic thanks for that. My mistake. I believed (erroneously) that FATAL => 'all' caused all calls to warn to die. Having reread the documentation it appears I still don't get FATAL => 'all' - do you know where that is documented? I can only find FATAL mentioned in perldoc warnings but it is not clear how this works.

        I still don't get FATAL => 'all' - do you know where that is documented?
        From warnings, follow the link to perllexwarn -> Fatal Warnings (I just added this to the OP as well).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://931066]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 17:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found