2 * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
19 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
22 %module "Amanda::Debug"
23 %include "amglue/amglue.swg"
24 %include "exception.i"
26 %include "Amanda/Debug.pod"
37 amglue_export_tag(init,
38 debug_init dbopen dbreopen dbrename dbclose
42 void debug_init(void);
43 void dbopen(char *subdir);
44 void dbreopen(char *file, char *notation);
45 void dbrename(char *config, char *subdir);
48 int error_exit_status;
51 * Override die() and warn()
56 # undef -> parsing module/eval
57 # 1 -> executing an eval
59 # we *only* want to call critical() in the "otherwise" case
60 if (!defined($^S) or $^S == 1) {
65 suppress_error_traceback();
69 $SIG{__DIE__} = \&_my_die;
76 $SIG{__WARN__} = \&_my_warn;
78 # utility function for test scripts, which want to use the regular
80 sub disable_die_override {
82 delete $SIG{__WARN__};
90 %rename(error) error__; /* error() is a macro defined in debug.h .. just avoid that */
92 void error__(char *msg) { g_error("%s", msg); }
93 void critical(char *msg) { g_critical("%s", msg); }
94 void warning(char *msg) { g_warning("%s", msg); }
95 void message(char *msg) { g_message("%s", msg); }
96 void info(char *msg) { g_info("%s", msg); }
97 void debug(char *msg) { g_debug("%s", msg); }
100 amglue_export_tag(logging,
101 error critical warning message info debug
104 void add_amanda_log_handler(amanda_log_handler_t *handler);
105 /* these functions are written as simple global variables, since they are just
106 * function pointers used in add_amanda_log_handler. Note that the functions
107 * then appear as e.g., $amanda_log_null. */
109 amanda_log_handler_t *amanda_log_stderr, *amanda_log_syslog, *amanda_log_null;
112 amglue_export_tag(logging,
113 add_amanda_log_handler
114 $amanda_log_stderr $amanda_log_syslog $amanda_log_null
117 /* used to suppress the traceback when calling from perl */
118 void suppress_error_traceback(void);
126 void debug_dup_stderr_to_debug(void);