Merge branch 'collectd-5.4'
[collectd.git] / contrib / collection3 / lib / Collectd / Graph / TypeLoader.pm
index c5fe613..3d6f61e 100644 (file)
@@ -6,7 +6,7 @@ Collectd::Graph::TypeLoader - Load a module according to the "type"
 
 =cut
 
-# Copyright (C) 2008  Florian octo Forster <octo at verplant.org>
+# Copyright (C) 2008,2009  Florian octo Forster <octo at verplant.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
 # the terms of the GNU General Public License as published by the Free Software
@@ -34,7 +34,7 @@ use Collectd::Graph::Type ();
 @Collectd::Graph::TypeLoader::EXPORT_OK = ('tl_load_type');
 
 our @ArrayMembers = (qw(data_sources rrd_opts custom_order));
-our @ScalarMembers = (qw(rrd_title rrd_format rrd_vertical scale));
+our @ScalarMembers = (qw(rrd_title rrd_format rrd_vertical scale ignore_unknown stacking));
 our @DSMappedMembers = (qw(ds_names rrd_colors));
 
 our %MemberToConfigMap =
@@ -47,7 +47,9 @@ our %MemberToConfigMap =
   rrd_vertical => 'rrdverticallabel',
   rrd_colors => 'color',
   scale => 'scale', # GenericIO only
-  custom_order => 'order' # GenericStacked only
+  custom_order => 'order', # GenericStacked only
+  stacking => 'stacking', # GenericStacked only
+  ignore_unknown => 'ignoreunknown' # GenericStacked only
 );
 
 return (1);
@@ -57,8 +59,9 @@ sub _create_object
   my $module = shift;
   my $obj;
 
-  local $SIG{__WARN__} = sub {};
-  local $SIG{__DIE__} = sub {};
+  # Suppress warnings and error messages caused by the eval.
+  local $SIG{__WARN__} = sub { return (1); print STDERR "WARNING: " . join (', ', @_) . "\n"; };
+  local $SIG{__DIE__}  = sub { return (1); print STDERR "FATAL: "   . join (', ', @_) . "\n"; };
 
   eval <<PERL;
   require $module;
@@ -89,7 +92,8 @@ sub _load_module_from_config
     $obj = _create_object ($module);
     if (!$obj)
     {
-      cluck ("Creating an $module object failed");
+      #cluck ("Creating an $module object failed");
+      warn ("Creating an $module object failed");
       return;
     }
   }