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
Make level_is_valid() able to validate - and canonicalise - levels given as
numbers, not just names
Remove redundant canonicalisation of numerical level from log()
In _level_as_number(), only return given level once validation has occurred
In _level_as_number(), following validation, only return the level as-is if it
looks like an unsigned integer of any length [1]
In _level_as_name(), also check - and canonicalise - the given level with
level_is_valid() [2]
In _level_as_name(), following validation, only return the level as-is if it
does not look like an unsigned integer of any length [1]
Use ASCII-safe semantics (can't use /a modifier but [0-9] is safer than \d)
Where min_level/max_level are specified incorrectly, croak instead of dying
In _basic_init, use eval to suppress exceptions raised by _level_as_number(),
so that we can continue to throw user-friendly exceptions where min_level or
max_level are specified incorrectly
[1] DRY principle; validation having already been conducted by level_is_valid()
[2] Establishes symmetry with _level_as_number(), which also validates
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:-
[1] DRY principle; validation having already been conducted by level_is_valid() [2] Establishes symmetry with _level_as_number(), which also validates