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