Make content log file configurable
This commit is contained in:
parent
5375c9818d
commit
b8e5e0a1b9
@ -16,6 +16,16 @@ Useful for debugging other plugins or keeping an archive of things.
|
|||||||
Used to enable and disable content logging
|
Used to enable and disable content logging
|
||||||
|
|
||||||
Default: true
|
Default: true
|
||||||
|
|
||||||
|
=head2 content_log_file <pattern>
|
||||||
|
|
||||||
|
Path to the content log file.
|
||||||
|
|
||||||
|
This option is passed through strftime(); see
|
||||||
|
http://man7.org/linux/man-pages/man3/strftime.3.html
|
||||||
|
or the appropriate documentation for your operating system)
|
||||||
|
|
||||||
|
Default: mail/%Y%m%d
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
use POSIX qw:strftime:;
|
use POSIX qw:strftime:;
|
||||||
@ -47,9 +57,11 @@ sub data_post_handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub content_log_file {
|
sub content_log_file {
|
||||||
|
my ( $self ) = @_;
|
||||||
# as a decent default, log on a per-day-basis
|
# as a decent default, log on a per-day-basis
|
||||||
my $date = strftime("%Y%m%d", localtime(time));
|
my $path = $self->qp->config('content_log_file');
|
||||||
return "mail/$date";
|
$path ||= 'mail/%Y%m%d';
|
||||||
|
return strftime($path, localtime(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
sub content_log_enabled {
|
sub content_log_enabled {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use POSIX qw( strftime );
|
||||||
|
|
||||||
sub register_tests {
|
sub register_tests {
|
||||||
my ( $self ) = @_;
|
my ( $self ) = @_;
|
||||||
@ -12,7 +13,15 @@ sub register_tests {
|
|||||||
|
|
||||||
sub test_content_log_file {
|
sub test_content_log_file {
|
||||||
my ( $self ) = @_;
|
my ( $self ) = @_;
|
||||||
ok( $self->content_log_file, 'content_log_file() returns something' );
|
is( $self->content_log_file,
|
||||||
|
strftime('mail/%Y%m%d', localtime(time)),
|
||||||
|
'content_log_file() returns the right default value' );
|
||||||
|
$self->save_hook;
|
||||||
|
$self->fake_config('/path/to/%Y%m%d%H%M');
|
||||||
|
is( $self->content_log_file,
|
||||||
|
strftime('/path/to/%Y%m%d%H%M', localtime(time)),
|
||||||
|
'content_log_file config changes content_log_file() output' );
|
||||||
|
$self->restore_hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub test_content_log_enabled {
|
sub test_content_log_enabled {
|
||||||
|
Loading…
Reference in New Issue
Block a user