[pve-devel] r5400 - in pve-cluster/trunk/data: . perl

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Jan 19 14:55:44 CET 2011


Author: dietmar
Date: 2011-01-19 14:55:44 +0100 (Wed, 19 Jan 2011)
New Revision: 5400

Modified:
   pve-cluster/trunk/data/ChangeLog
   pve-cluster/trunk/data/perl/Cluster.pm
Log:
	(log_msg): allow to use 'symbolic' priority names



Modified: pve-cluster/trunk/data/ChangeLog
===================================================================
--- pve-cluster/trunk/data/ChangeLog	2011-01-19 13:54:11 UTC (rev 5399)
+++ pve-cluster/trunk/data/ChangeLog	2011-01-19 13:55:44 UTC (rev 5400)
@@ -1,6 +1,7 @@
 2011-01-19  root  <root at maui.maurer-it.com>
 
 	* perl/Cluster.pm (log_msg): fixes for taint mode (untaint $0)
+	(log_msg): allow to use 'symbolic' priority names
 
 2010-11-17  Proxmox Support Team  <support at proxmox.com>
 

Modified: pve-cluster/trunk/data/perl/Cluster.pm
===================================================================
--- pve-cluster/trunk/data/perl/Cluster.pm	2011-01-19 13:54:11 UTC (rev 5399)
+++ pve-cluster/trunk/data/perl/Cluster.pm	2011-01-19 13:55:44 UTC (rev 5400)
@@ -465,15 +465,30 @@
     PVE::Tools::file_set_contents($fsname, $raw);
 }
 
+my $log_levels = {
+    "emerg" => 0,
+    "alert" => 1,
+    "crit" => 2,
+    "critical" => 2,
+    "err" => 3,
+    "error" => 3,
+    "warn" => 4,
+    "warning" => 4,
+    "notice" => 5,
+    "info" => 6,
+    "debug" => 7,
+};
+
 sub log_msg {
    my ($priority, $ident, $msg) = @_;
 
+   if (my $tmp = $log_levels->{$priority}) {
+       $priority = $tmp;
+   }
+
    die "need numeric log priority" if $priority !~ /^\d+$/;
 
-   my $tag = "clusterlog";
-   if ($0 =~ m|^(.*/)?(.+)$|) { # untaint
-       $tag = $2;
-   }
+   my $tag = PVE::SafeSyslog::tag();
 
    $msg = "empty message" if !$msg;
 




More information about the pve-devel mailing list