Add method to exclude messages from content log

This commit is contained in:
Jared Johnson 2014-12-02 17:13:00 -06:00
parent edc8f7600d
commit e95f1e294e
2 changed files with 14 additions and 0 deletions

View File

@ -14,6 +14,9 @@ sub register {
sub data_post_handler { sub data_post_handler {
my ($self, $transaction) = @_; my ($self, $transaction) = @_;
return DECLINED, 'excluded from content logging'
if $self->exclude();
open my $out, '>>', $self->content_log_file open my $out, '>>', $self->content_log_file
or return DECLINED, "Could not open log file.. continuing anyway"; or return DECLINED, "Could not open log file.. continuing anyway";
@ -41,3 +44,8 @@ sub content_log_enabled {
return 1 if lc($enabled) eq 'true'; return 1 if lc($enabled) eq 'true';
return 0; return 0;
} }
sub exclude {
# override this method to exclude some messages from content logging
return 0;
}

View File

@ -7,6 +7,7 @@ sub register_tests {
my ( $self ) = @_; my ( $self ) = @_;
$self->register_test('test_content_log_file'); $self->register_test('test_content_log_file');
$self->register_test('test_content_log_enabled'); $self->register_test('test_content_log_enabled');
$self->register_test('test_exclude');
} }
sub test_content_log_file { sub test_content_log_file {
@ -19,3 +20,8 @@ sub test_content_log_enabled {
ok( ! $self->content_log_enabled, 'content_log_enabled() returns false' ); ok( ! $self->content_log_enabled, 'content_log_enabled() returns false' );
} }
sub test_exclude {
my ( $self ) = @_;
ok( ! $self->exclude, 'exclude() default method returns false' );
}