[pve-devel] r5399 - in pve-common/trunk/data: . PVE

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Jan 19 14:54:11 CET 2011


Author: dietmar
Date: 2011-01-19 14:54:11 +0100 (Wed, 19 Jan 2011)
New Revision: 5399

Modified:
   pve-common/trunk/data/ChangeLog
   pve-common/trunk/data/PVE/SafeSyslog.pm
Log:
* PVE/SafeSyslog.pm (tag): a way to read the log tag


Modified: pve-common/trunk/data/ChangeLog
===================================================================
--- pve-common/trunk/data/ChangeLog	2011-01-19 12:57:23 UTC (rev 5398)
+++ pve-common/trunk/data/ChangeLog	2011-01-19 13:54:11 UTC (rev 5399)
@@ -1,3 +1,7 @@
+2011-01-19  root  <root at maui.maurer-it.com>
+
+	* PVE/SafeSyslog.pm (tag): a way to read the log tag
+
 2011-01-12  root  <root at maui.maurer-it.com>
 
 	* INotify.pm (read/write_etc_resolv_conf): functions to read/write

Modified: pve-common/trunk/data/PVE/SafeSyslog.pm
===================================================================
--- pve-common/trunk/data/PVE/SafeSyslog.pm	2011-01-19 12:57:23 UTC (rev 5398)
+++ pve-common/trunk/data/PVE/SafeSyslog.pm	2011-01-19 13:54:11 UTC (rev 5399)
@@ -2,7 +2,9 @@
 
 use strict;
 use warnings;
+use File::Basename;
 use Sys::Syslog ();
+use Encode;
 
 use vars qw($VERSION @ISA @EXPORT);
 
@@ -13,6 +15,8 @@
 @ISA = qw(Exporter);
 
 @EXPORT = qw(syslog initlog);
+
+my $log_tag = "unknown";
  
 # never log to console - thats too slow, and
 # it corrupts the DBD database connection!
@@ -22,12 +26,24 @@
 }
 
 sub initlog {
-    my ($ident, $facility) = @_;
+    my ($tag, $facility) = @_;
 
+    if ($tag) { 
+	$tag = basename($tag);
+
+	$tag = encode("ascii", decode_utf8($tag));
+
+	$log_tag = $tag;
+    }
+
     # never log to console - thats too slow
     Sys::Syslog::setlogsock ('unix');
 
-    Sys::Syslog::openlog ($ident, 'pid', $facility);
+    Sys::Syslog::openlog ($log_tag, 'pid', $facility);
 }
 
+sub tag {
+    return $log_tag;
+}
+
 1;



More information about the pve-devel mailing list