2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2017 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * Define Message Types for Bacula
43 * Most of these message levels are more or less obvious.
44 * They have evolved somewhat during the development of Bacula,
45 * and here are some of the details of where I am trying to
46 * head (in the process of changing the code) as of 15 June 2002.
48 * M_ABORT Bacula immediately aborts and tries to produce a traceback
49 * This is for really serious errors like segmentation fault.
50 * M_ERROR_TERM Bacula immediately terminates but no dump. This is for
51 * "obvious" serious errors like daemon already running or
52 * cannot open critical file, ... where a dump is not wanted.
53 * M_TERM Bacula daemon shutting down because of request (SIGTERM).
55 * The remaining apply to Jobs rather than the daemon.
57 * M_FATAL Bacula detected a fatal Job error. The Job will be killed,
58 * but Bacula continues running.
59 * M_ERROR Bacula detected a Job error. The Job will continue running
60 * but the termination status will be error.
61 * M_WARNING Job warning message.
62 * M_INFO Job information message.
64 * M_RESTORED An ls -l of each restored file.
66 * M_SECURITY For security viloations. This is equivalent to FATAL.
67 * (note, this is currently being implemented in 1.33).
69 * M_ALERT For Tape Alert messages.
71 * M_VOLMGMT Volume Management message
73 * M_DEBUG and M_SAVED are excluded from M_ALL by default
77 /* Keep M_ABORT=1 for dlist.h */
78 M_ABORT = 1, /* MUST abort immediately */
79 M_DEBUG, /* debug message */
80 M_FATAL, /* Fatal error, stopping job */
81 M_ERROR, /* Error, but recoverable */
82 M_WARNING, /* Warning message */
83 M_INFO, /* Informational message */
84 M_SAVED, /* Info on saved file */
85 M_NOTSAVED, /* Info on notsaved file */
86 M_SKIPPED, /* File skipped during backup by option setting */
87 M_MOUNT, /* Mount requests */
88 M_ERROR_TERM, /* Error termination request (no dump) */
89 M_TERM, /* Terminating daemon normally */
90 M_RESTORED, /* ls -l of restored files */
91 M_SECURITY, /* security violation */
92 M_ALERT, /* tape alert messages */
93 M_VOLMGMT /* Volume management messages */
96 #define M_MAX M_VOLMGMT /* keep this updated ! */
98 /* Define message destination structure */
99 /* *** FIXME **** where should be extended to handle multiple values */
100 typedef struct s_dest {
102 int dest_code; /* destination (one of the MD_ codes) */
103 int max_len; /* max mail line length */
104 FILE *fd; /* file descriptor */
105 char msg_types[nbytes_for_bits(M_MAX+1)]; /* message type mask */
106 char *where; /* filename/program name */
107 char *mail_cmd; /* mail command */
108 POOLMEM *mail_filename; /* unique mail filename */
111 /* Message Destination values for dest field of DEST */
113 MD_SYSLOG = 1, /* send msg to syslog */
114 MD_MAIL, /* email group of messages */
115 MD_FILE, /* write messages to a file */
116 MD_APPEND, /* append messages to a file */
117 MD_STDOUT, /* print messages */
118 MD_STDERR, /* print messages to stderr */
119 MD_DIRECTOR, /* send message to the Director */
120 MD_OPERATOR, /* email a single message to the operator */
121 MD_CONSOLE, /* send msg to UserAgent or console */
122 MD_MAIL_ON_ERROR, /* email messages if job errors */
123 MD_MAIL_ON_SUCCESS, /* email messages if job succeeds */
124 MD_CATALOG /* sent to catalog Log table */
127 /* Queued message item */
136 #define DEBUG_CLEAR_FLAGS /* 0 clear debug_flags */
137 #define DEBUG_NO_WIN32_WRITE_ERROR /* i continue even after win32 errors */
138 #define DEBUG_WIN32DECOMP /* d */
139 #define DEBUG_DBG_TIMESTAMP /* t turn on timestamp in trace file */
140 #define DEBUG_DBG_NO_TIMESTAMP /* T turn off timestamp in trace file */
141 #define DEBUG_TRUNCATE_TRACE /* c clear trace file if opened */
143 /* Bits (1, 2, 4, ...) for debug_flags used by set_debug_flags() */
144 #define DEBUG_MUTEX_EVENT (1 << 0) /* l */
145 #define DEBUG_PRINT_EVENT (1 << 1) /* p */
147 /* Tags that can be used with the setdebug command
148 * We can extend this list to use 64bit
149 * When adding new ones, keep existing one
150 * Corresponding strings are defined in messages.c (debugtags)
152 #define DT_LOCK (1<<30) /* lock */
153 #define DT_NETWORK (1<<29) /* network */
154 #define DT_PLUGIN (1<<28) /* plugin */
155 #define DT_VOLUME (1<<27) /* volume */
156 #define DT_SQL (1<<26) /* sql */
157 #define DT_BVFS (1<<25) /* bvfs */
158 #define DT_MEMORY (1<<24) /* memory */
159 #define DT_SCHEDULER (1<<23) /* scheduler */
160 #define DT_PROTOCOL (1<<22) /* protocol */
161 #define DT_xxxxx (1<<21) /* reserved BEE */
162 #define DT_xxx (1<<20) /* reserved BEE */
163 #define DT_SNAPSHOT (1<<19) /* Snapshot */
164 #define DT_ASX (1<<16) /* used by Alain for personal debugging */
165 #define DT_ALL (0x7FFF0000) /* all (up to debug_level 65635, 15 flags available) */
167 const char *debug_get_tag(uint32_t pos, const char **desc);
168 bool debug_find_tag(const char *tagname, bool add, int64_t *current_level);
169 bool debug_parse_tags(const char *options, int64_t *current_level);
172 void d_msg(const char *file, int line, int64_t level, const char *fmt,...) CHECK_FORMAT(printf, 4, 5);
173 void e_msg(const char *file, int line, int type, int level, const char *fmt,...) CHECK_FORMAT(printf, 5, 6);;
174 void Jmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...) CHECK_FORMAT(printf, 4, 5);
175 void Qmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...) CHECK_FORMAT(printf, 4, 5);
176 bool get_trace(void);
177 void set_debug_flags(char *options);
178 const char *get_basename(const char *pathname);
179 bool is_message_type_set(JCR *jcr, int type);
181 class BDB; /* define forward reference */
182 typedef bool (*sql_query_call)(JCR *jcr, const char *cmd);
183 typedef bool (*sql_escape_call)(JCR *jcr, BDB *db, char *snew, char *sold, int len);
185 extern DLL_IMP_EXP sql_query_call p_sql_query;
186 extern DLL_IMP_EXP sql_escape_call p_sql_escape;
188 extern DLL_IMP_EXP int64_t debug_level;
189 extern DLL_IMP_EXP int64_t debug_level_tags;
190 extern DLL_IMP_EXP int32_t debug_flags;
191 extern DLL_IMP_EXP bool dbg_timestamp; /* print timestamp in debug output */
192 extern DLL_IMP_EXP bool prt_kaboom; /* Print kaboom output */
193 extern DLL_IMP_EXP int verbose;
194 extern DLL_IMP_EXP char my_name[];
195 extern DLL_IMP_EXP const char * working_directory;
196 extern DLL_IMP_EXP utime_t daemon_start_time;
198 extern DLL_IMP_EXP bool console_msg_pending;
199 extern DLL_IMP_EXP FILE * con_fd; /* Console file descriptor */
200 extern DLL_IMP_EXP brwlock_t con_lock; /* Console lock structure */