Imported Upstream version 2.6.1
[debian/amanda] / perl / Amanda / Debug.pm
index ad6795f942e17bad8a790419199ca72313d87d83..fc1d6b1a44170f39d68d69bd72a536277f44e189 100644 (file)
@@ -1,5 +1,5 @@
 # This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
 #
 # Don't modify this file, modify the SWIG interface instead.
 
@@ -49,6 +49,7 @@ sub this {
 
 package Amanda::Debug;
 
+*debug_init = *Amanda::Debugc::debug_init;
 *dbopen = *Amanda::Debugc::dbopen;
 *dbreopen = *Amanda::Debugc::dbreopen;
 *dbrename = *Amanda::Debugc::dbrename;
@@ -82,15 +83,14 @@ Amanda::Debug - support for debugging Amanda applications
 
 =head1 SYNOPSIS
 
-  use Amanda::Debug qw( :init :logging );
+  use Amanda::Util qw( :constants );
 
-  # (note: dbopen and such are usually handled by 
-  #  Amanda::Util::setup_applicaton)
-  dbopen("server");
+  Amanda::Util::setup_application("amcooltool", "server", $CONTEXT_CMDLINE);
 
   debug("this is a debug message");
+  die("Unable to frobnicate the ergonator");
 
-See C<debug.h> for a more in-depth description of the functionality of
+See C<debug.h> for a more in-depth description of the logging functionality of
 this module.
 
 =head1 API STATUS
@@ -99,7 +99,7 @@ Stable
 
 =head1 DEBUG LOGGING
 
-Several debug logging messages, each taking a single string, are
+Several debug logging functions, each taking a single string, are
 available:
 
 =over
@@ -118,7 +118,10 @@ available:
 
 =back
 
-ALl of the debug logging functions are available via the export tag
+Perl's built-in C<die> and C<warn> functions are patched to call C<critical>
+and C<warning>, respectively. 
+
+All of the debug logging functions are available via the export tag
 C<:logging>.
 
 =head1 ADVANCED USAGE
@@ -157,9 +160,9 @@ applications which may produce error output.
 
 =cut
 
-push @EXPORT_OK, qw(dbopen dbreopen dbrename dbclose
+push @EXPORT_OK, qw(debug_init dbopen dbreopen dbrename dbclose
     $erroutput_type $error_exit_status);
-push @{$EXPORT_TAGS{"init"}}, qw(dbopen dbreopen dbrename dbclose
+push @{$EXPORT_TAGS{"init"}}, qw(debug_init dbopen dbreopen dbrename dbclose
     $erroutput_type $error_exit_status);
 
 push @EXPORT_OK, qw(erroutput_type_t_to_strings);
@@ -203,6 +206,33 @@ push @{$EXPORT_TAGS{"erroutput_type_t"}}, qw($ERR_AMANDALOG);
 
 $_erroutput_type_t_VALUES{"AMANDALOG"} = $ERR_AMANDALOG;
 
+sub _my_die {
+    # $^S is set if we're in an eval { .. }, in which case we want
+    # to use the default Perl semantics.
+    if ($^S) {
+       die(@_);
+    } else {
+       my ($msg) = @_;
+       chomp $msg;
+       critical(@_);
+    }
+};
+$SIG{__DIE__} = \&my_die;
+
+sub _my_warn {
+    my ($msg) = @_;
+    chomp $msg;
+    warning(@_);
+};
+$SIG{__WARN__} = \&my_warn;
+
+# utility function for test scripts, which want to use the regular
+# perl mechanisms
+sub disable_die_override {
+    delete $SIG{__DIE__};
+    delete $SIG{__WARN__};
+}
+
 push @EXPORT_OK, qw(error critical warning message info debug);
 push @{$EXPORT_TAGS{"logging"}}, qw(error critical warning message info debug);
 1;