diff options
author | Jonas Smedegaard <dr@jones.dk> | 2024-09-01 10:49:20 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2024-09-01 16:31:49 +0200 |
commit | 34c35912a4b457c4240c31b956f93c4d87726427 (patch) | |
tree | bc34ec43c1ea0e0f064dc516bc1245bb0f198df1 | |
parent | fac3b4444183ec38924cdf5c2878965b33be3992 (diff) |
streamline logging
-rwxr-xr-x | bin/events2md.pl | 7 | ||||
-rw-r--r-- | lib/Object/Groupware.pm | 4 | ||||
-rw-r--r-- | lib/Object/Groupware/Calendar.pm | 9 | ||||
-rw-r--r-- | lib/Object/Groupware/Event.pm | 9 |
4 files changed, 13 insertions, 16 deletions
diff --git a/bin/events2md.pl b/bin/events2md.pl index 7192cb0..b0772d3 100755 --- a/bin/events2md.pl +++ b/bin/events2md.pl @@ -25,6 +25,9 @@ use Object::Groupware::Calendar; if ( IO::Interactive::Tiny::is_interactive() ) { Log::Any::Adapter->set( 'Screen', default_level => 'info' ); } +else { + use Log::Any::Adapter ( 'Stderr', default_level => 'info' ); +} # set defaults and parse command-line options my ($BASE_URI, $CALENDAR_URI, $SKELDIR, $OUTPUT_FILE, $CALENDAR_LANG, @@ -135,10 +138,6 @@ elsif ( $base_uri->scheme eq 'file' ) { ); } } -if ( $log->is_trace ) { - use DDP; - p $calendar; -} # select subset of calendar events $log->debug('serialize calendar events...'); diff --git a/lib/Object/Groupware.pm b/lib/Object/Groupware.pm index 083f415..a49b47b 100644 --- a/lib/Object/Groupware.pm +++ b/lib/Object/Groupware.pm @@ -20,7 +20,7 @@ ADJUST { $dt_locale = DateTime::Locale->load( $self->dt_locale ) unless $self->dt_locale isa DateTime::Locale::FromData; $log->debugf( - 'Class %s set up to use locale %s (%s)', + 'Object %s locale: %s (%s)', __CLASS__, $self->dt_locale->code, $self->dt_locale->name ); } @@ -28,7 +28,7 @@ ADJUST { $dt_time_zone = DateTime::TimeZone->new( name => $self->dt_time_zone ) unless $self->dt_time_zone isa DateTime::TimeZone; $log->debugf( - 'Class %s set up to use time zone %s', + 'Object %s time zone: %s', __CLASS__, $self->dt_time_zone->name ); } diff --git a/lib/Object/Groupware/Calendar.pm b/lib/Object/Groupware/Calendar.pm index 3d46032..d51e833 100644 --- a/lib/Object/Groupware/Calendar.pm +++ b/lib/Object/Groupware/Calendar.pm @@ -9,6 +9,7 @@ use utf8; use Log::Any qw( ); use Data::ICal::DateTime; +use Encode qw(decode_utf8); use Object::Groupware::Event; @@ -25,10 +26,10 @@ ADJUST { } elsif ($filename) { $data = Data::ICal->new( filename => $filename ) } - if ( $log->is_trace ) { - use DDP; - p $data; - } + $log->tracef( + "Object %s contents:\n%s", __CLASS__, + decode_utf8 $data->as_string + ); } # mimick Data::ICal::DateTime::events() signature diff --git a/lib/Object/Groupware/Event.pm b/lib/Object/Groupware/Event.pm index 270028e..7384176 100644 --- a/lib/Object/Groupware/Event.pm +++ b/lib/Object/Groupware/Event.pm @@ -10,6 +10,7 @@ use utf8; use Log::Any qw( ); use Feature::Compat::Try; use DateTime::Locale; +use Encode qw(decode_utf8); field $log = Log::Any->get_logger; @@ -67,12 +68,8 @@ ADJUST { } } - if ( $log->is_trace ) { - use DDP; - p $entry; - p $start; - p $end; - } + $log->tracef( "Object %s contents:\n%s", __CLASS__, + decode_utf8 $entry->as_string ); } method attendees { !!@attendees ? [@attendees] : undef } |