Skip to content

Commit

Permalink
Merge pull request #80 from stdweird/object_fake_logger_report
Browse files Browse the repository at this point in the history
CAF::Object add report method to conditional logger
  • Loading branch information
jrha committed Feb 9, 2015
2 parents 2cb1018 + 55efa00 commit 7185a4e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/main/perl/Object.pm
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ sub _initialize {
return undef;
}

=item error, warn, info, verbose, debug
=item error, warn, info, verbose, debug, report
Convenience methods to acess the log instance that might
Convenience methods to access the log instance that might
be passed during initialisation and set to $self->log.
(When constructing classes via multiple inheritance,
Expand All @@ -136,7 +136,7 @@ to use an absolute rather than a conditional logger).
=cut

no strict 'refs';
foreach my $i (qw(error warn info verbose debug)) {
foreach my $i (qw(error warn info verbose debug report)) {
*{$i} = sub {
my ($self, @args) = @_;
return $self->{log}->$i(@args) if $self->{log};
Expand Down
16 changes: 15 additions & 1 deletion src/main/perl/TextRender.pm
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,22 @@ sub render_properties
{
my ($self) = @_;

my $config = Config::Properties->new(order => 'alpha'); # order results
# recent versions of Config::Properties support order => 'alpha'
# for aplabetic key sorting when writing
# Default is 'keep', based on linenumbers. In the usage here, it
# means first parsed entry is on first line. For an unordered hash,
# this is not predicatable/reproducable. So we will sort the linenumbers
# and use linenumber sorted output.
my $config = Config::Properties->new(order => 'keep');
$config->setFromTree($self->{contents});

# force linenumbers
my $line=1;
foreach my $k (sort(keys %{$config->{properties}})) {
$config->{property_line_numbers}{$k} = $line;
$line++;
}

return $config->saveToString();
}

Expand Down

0 comments on commit 7185a4e

Please sign in to comment.