use Try::Tiny;
use Object::Remote;
use Object::Remote::Future;
-use Log::Contextual::WarnLogger;
-use Log::Contextual qw( :log ),
- -default_logger => Log::Contextual::WarnLogger->new({
- env_prefix => 'SI_REPORT_MEDIAWIKI',
- levels => [qw( error warn info debug trace )],
- });
+use System::Introspector::Report::Logging qw( :log );
use aliased 'System::Introspector::Report::Publish::MediaWiki::Updater';
sprintf "Pushing reports to MediaWiki at '%s'", $self->api_uri;
};
for my $page (sort keys %$pages) {
+ log_verbose { "Publishing $page" };
my $options = $pages->{$page};
if ($page =~ m{\%\(meta:(.+?)\)}) {
$self->_publish_dynamic($reports, $page, $1, $options);
}
else {
+ log_trace { "Standard page: $page" };
$self->_publish_pages([$reports, $page, $options]);
}
}
sub _publish_pages {
my ($self, @pages) = @_;
+ log_trace { sprintf "Publishing %i pages", scalar(@pages) };
my $stream = sub {
my $next = shift @pages
or return undef;
return [$page_name, $options, $sorted];
};
await_all map {
+ log_trace {
+ sprintf "Creating process to handle %i items from the update pool",
+ scalar(@{ $self->updater_pool }) };
$_->start::process($stream);
} @{ $self->updater_pool };
}
sub _sort_reports {
my ($self, $reports, $included) = @_;
+ log_trace { "Sorting reports" };
my @matchers = map {
$self->_prepare_matcher_from($_);
} ref($included) ? @{$included} : $included;
sub _publish_dynamic {
my ($self, $reports, $page_name, $key, $options) = @_;
+ log_debug { "Creating pages for dynamic page '$page_name'" };
my %reports_by_key;
for my $report (@$reports) {
my $value = $report->{meta}{$key};
my $assoc = $reports_by_key{$value};
push @pages, [$assoc, $effective_page, $options];
}
+ log_trace {
+ sprintf "%i pages were created for '%s'; publishing them",
+ scalar(@pages), $page_name
+ };
$self->_publish_pages(@pages);
return 1;
}
use Moo;
use Try::Tiny;
use Module::Runtime qw( use_module );
-use Log::Contextual::WarnLogger;
-use Log::Contextual qw( :log ),
- -default_logger => Log::Contextual::WarnLogger->new({
- env_prefix => 'SI_REPORT_MEDIAWIKI_UPDATER',
- levels => [qw( error warn info debug trace )],
- });
+use System::Introspector::Report::Logging qw( :log );
has connection => (is => 'ro', lazy => 1, builder => 1, handles => {
get_page => 'get',
sub process {
my ($self, $stream) = @_;
+ log_debug { "Updater is starting to process individual pages" };
while (my $report = $stream->()) {
+ log_trace { "Processing page" };
$self->_process_page(@$report);
}
return 1;
sub _process_page {
my ($self, $page_name, $options, $reports) = @_;
unless (scalar @$reports) {
- log_debug { "Skipping page '$page_name': No reports to publish" };
+ log_verbose { "Skipping page '$page_name': No reports to publish" };
return 1;
}
my $do_create = $options->{create};
return try {
my $page = $self->get_page($page_name);
if ($page->is_new and not $do_create) {
- log_trace { "Skipping page '$page_name': Does not yet exist" };
+ log_verbose { "Skipping page '$page_name': Does not yet exist" };
return 1;
}
my $is_changed = $page->update($reports);
unless ($is_changed) {
- log_debug { "Not pushing page '$page_name': No changes" };
+ log_verbose { "Not pushing page '$page_name': No changes" };
return 1;
}
- log_debug { "Updating page '$page_name'" };
+ log_info { "Updating page '$page_name'" };
$self->put_page($page);
return 1;
}
use JSON::PP;
use IO::All;
use Module::Runtime qw( use_module );
-use Log::Contextual::WarnLogger;
-use Log::Contextual qw( :log ),
- -default_logger => Log::Contextual::WarnLogger->new({
- env_prefix => 'SI_REPORT_SOURCE',
- levels => [qw( error warn info debug trace )],
- });
+use System::Introspector::Report::Logging qw( :log :dlog );
my $_json = JSON::PP->new->utf8->relaxed->allow_nonref;
my @dirs = $self->_find_source_dirs;
for my $dir_spec (@dirs) {
my ($id, $path) = @$dir_spec;
+ log_debug { "Starting to load dataset for node '$id' from '$path' " };
my $data = $self->_load_dataset($path, $required)
or next;
- log_trace { "loading node '$id' from '$path'" };
+ log_verbose { "Collecting data from node '$id'" };
$_->collect_from($id, $data)
for @generators;
}
sub _find_source_dirs {
my ($self) = @_;
my $root = $self->root;
- return map {
+ return Dlog_trace { "Discovered source dirs: $_" } map {
(my $id = $_) =~ s{^\Q$root\E/*}{};
[$id, $_];
} io($root)->all_dirs;