houseabsolute / Log-Dispatch

Dispatches messages to one or more outputs
https://metacpan.org/release/Log-Dispatch/
Other
12 stars 29 forks source link

Improve level validation and canonicalisation logic #34

Closed ghost closed 7 years ago

ghost commented 7 years ago

Having started working on RT bug #106495, I subsequently realised that the issue had been resolved with GitHub PR #15. As I have a handful of modest improvements left over from this work, I figured that I might as well submit them.

Note that this patch addresses the following discrepancy:-

# Assuming one log output where min_level = 0 ...
$dispatcher->is_debug()         # is true
$dispatcher->would_log('debug') # is true
$dispatcher->would_log(0)       # is false

[1] DRY principle; validation having already been conducted by level_is_valid() [2] Establishes symmetry with _level_as_number(), which also validates