]> mj.ucw.cz Git - libucw.git/commitdiff
Added Log perl module.
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Fri, 16 Mar 2007 08:26:59 +0000 (09:26 +0100)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Fri, 16 Mar 2007 08:26:59 +0000 (09:26 +0100)
lib/perl/Log.pm [new file with mode: 0644]
lib/perl/Makefile

diff --git a/lib/perl/Log.pm b/lib/perl/Log.pm
new file mode 100644 (file)
index 0000000..68b1d37
--- /dev/null
@@ -0,0 +1,27 @@
+#
+#      Perl module for Logging
+#
+#      (c) 2007 Pavel Charvat <pchar@ucw.cz>
+#
+
+package Sherlock::Log;
+
+use lib 'lib/perl5';
+use strict;
+use warnings;
+use POSIX;
+
+my $Prog = (reverse split(/\//, $0))[0];
+
+sub Log {
+  my $level = shift;
+  my $text = join(' ', @_);
+  print STDERR $level, strftime(" %Y-%m-%d %H:%M:%S ", localtime()), "[$Prog] ", $text, "\n";
+}
+
+sub Die {
+  Log('!', @_);
+  exit 1;
+}
+
+1;
index a95678b64250a36b0037ca5190a8dd22eb200b1a..4f2cc056162d0dfb989272dae90a8415d231d149 100644 (file)
@@ -1,7 +1,7 @@
 # Perl modules
 
 DIRS+=lib/perl
-PROGS+=$(addprefix $(o)/lib/perl/,Config.pm)
+PROGS+=$(addprefix $(o)/lib/perl/,Config.pm Log.pm)
 
 ifdef CONFIG_UCW_PERL_ULIMIT
 include $(s)/lib/perl/Ulimit/Makefile