Hook::Filter

Hook::Filter is a runtime filtering layer on top of subroutine calls.
Download

Hook::Filter Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Erwan Lemonnier
  • Publisher web site:
  • http://search.cpan.org/~erwan/Sub-Contract-0.09/lib/Sub/Contract.pm

Hook::Filter Tags


Hook::Filter Description

Hook::Filter is a runtime filtering layer on top of subroutine calls. Hook::Filter is a runtime filtering layer on top of subroutine calls.SYNOPSISImagine you have a big program using a logging library that exports 3 functions called mydebug, myinfo and mywarn. Those functions generate far too much log, so you want to skip calling them except in some specific circumstances.In your main program, write: use Hook::Filter hook => ;In all modules making use of the logging library, write: use Hook::Filter;Then create a file called ./hook_filter.rules. This file contains boolean expressions that specify when calls to the filtered subroutines should be allowed: # allow calls to 'mydebug' only inside package 'My::Filthy:Attempt' is_sub('mydebug') && from_pkg('My::Filthy::Attempt') # allow all calls to 'myinfo' except from inside packages under the namespace My::Test:: is_sub('myinfo') && !from_pkg(/^My::Test/) # allow calls to 'mywarn' from function 'do_stuff' in package 'main' # whose third argument is a message that does not match the string 'invalid login name' is_sub('mywarn') && from_sub('do_stuff') && from_pkg('main') && !has_arg(3,/invalid login name/) # all other calls to 'myinfo', 'mydebug' or 'mywarn' will be skippedSYNOPSIS, Log::DispatchYour program uses Log::Dispatch. You want to enable Hook::Filter on top of the methods log and log_to from Log::Dispatch everywhere at once. And you want to use the filter rules located in /etc/myconf/filter_rules.conf. Easy: in main, write: use Hook::Filter rules => '/etc/myconf/filter_rules.conf', hook => ; Requirements: · Perl


Hook::Filter Related Software