preaction / Log-Any

Simple, fast Perl logging API compatible with any logging system
Other
13 stars 19 forks source link

Add `level_contains_ok()` to Log::Any::Test #75

Open alabamapaul opened 6 years ago

alabamapaul commented 6 years ago

The contains_ok() method is great, but it would be nice to specify a log level as well. Maybe something like: $log->level_contains_ok("warn", qr/Ooops/, "Found expected log message");

preaction commented 6 years ago

Yeah, that sounds like a great idea! I could even see adding it as an optional first argument to contains_ok (despite how ugly that'd make unpacking @_).

$log->contains_ok( qr{failed} ); # Log contains 'failed' at any level
$log->contains_ok( warn => qr{failed} ); # Log contains 'failed' at 'warn' level

Looking at the code, though, it doesn't look like the regex was ever required to be a regex, since it's just interpolated into a /.../, so it will indeed have to be level_contains_ok and level_does_not_contain_ok.