[Bps-public-commit] storage-box branch, master, updated. 181219b74395418fcc5bf2d975c97f7c9ecedaf8

Dave Goehrig dave at bestpractical.com
Fri Sep 30 11:38:45 EDT 2016


The branch, master has been updated
       via  181219b74395418fcc5bf2d975c97f7c9ecedaf8 (commit)
      from  2667b2eb31a3c2303cf445c281766bc5f26064b9 (commit)

Summary of changes:
 lib/Storage/Box/Logger.pm | 88 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)
 create mode 100644 lib/Storage/Box/Logger.pm

- Log -----------------------------------------------------------------
commit 181219b74395418fcc5bf2d975c97f7c9ecedaf8
Author: Dave Goehrig <dave at bestpractical.com>
Date:   Fri Sep 30 11:38:41 2016 -0400

    add missing file which didn't survive the merge

diff --git a/lib/Storage/Box/Logger.pm b/lib/Storage/Box/Logger.pm
new file mode 100644
index 0000000..1f0743c
--- /dev/null
+++ b/lib/Storage/Box/Logger.pm
@@ -0,0 +1,88 @@
+package Storage::Box::Logger;
+
+=pod
+
+=head1 NAME
+
+Storage::Box::Logger -- a delegatable logger for Storage::Box
+
+=head1 SYNOPSIS
+
+    my $logger = Log::Dispatch->new([outputs => [ 'Screen', min_level => 'debug' ]]);
+    Storage::Box::Logger::logger->delegate($logger);
+
+    or
+
+    $Storage::Box::Logger::debug = 1;
+
+=head1 DESCRIPTION
+
+Storage::Box::Logger provides basic logging for Storage::Box
+and allows one to delegate logging to another logging object
+such as one created by Log::Dispatch.  By default the logger 
+object responds to the typical logging messages:
+
+=over
+
+=item debug
+
+=item info
+
+=item warn
+
+=item error
+
+=item critical
+
+=back
+
+It will print all statuses except debug to STDERR if no 
+delegate is supplied.  If a delegate is supplied it will
+dispatch all logging to the delegate.
+
+=cut
+
+use Exporter;
+ at EXPORT = (logger);
+
+our $debug;
+our $delegate;
+our $logger = Storage::Box::Logger->new;
+
+sub AUTOLOAD {
+	my ($sub) = $AUTOLOAD =~ /::([^:]+)$/;
+	my $self = shift;
+	return $delegate->$sub(@_) if ($delegate && $delegate->can($sub));
+	print STDERR $@;
+}
+
+sub logger {
+    $logger;
+}
+
+sub new {
+	my $class = shift;
+	my $self = @_ ? ( @_ > 1 ? { @_ } : { %$_[0] } ) : {};
+	bless $self, ref $class || $class;
+}
+
+=pod
+
+=head1 AUTHOR 
+
+Dave Goehrig E<lt>dave at dloh.orgE<gt>
+
+=head1 COPYRIGHT
+
+Copyright (C) 2016 Best Practical Solutions, LLC.
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+
+=cut
+
+1;
+

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list