]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/message.h
======================= Warning ==========================
[bacula/bacula] / bacula / src / lib / message.h
1 /*
2  * Define Message Types for Bacula
3  *    Kern Sibbald, 2000
4  *
5  *   Version $Id$
6  */
7 /*
8    Copyright (C) 2000-2006 Kern Sibbald
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License
12    version 2 as amended with additional clauses defined in the
13    file LICENSE in the main source directory.
14
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
18    the file LICENSE for additional details.
19
20  */
21
22 #include "bits.h"
23
24 #undef  M_DEBUG
25 #undef  M_ABORT
26 #undef  M_FATAL
27 #undef  M_ERROR
28 #undef  M_WARNING
29 #undef  M_INFO
30 #undef  M_MOUNT
31 #undef  M_ERROR_TERM
32 #undef  M_TERM
33 #undef  M_RESTORED
34 #undef  M_SECURITY
35 #undef  M_ALERT
36
37 /*
38  * Most of these message levels are more or less obvious.
39  * They have evolved somewhat during the development of Bacula,
40  * and here are some of the details of where I am trying to
41  * head (in the process of changing the code) as of 15 June 2002.
42  *
43  *  M_ABORT       Bacula immediately aborts and tries to produce a traceback
44  *                  This is for really serious errors like segmentation fault.
45  *  M_ERROR_TERM  Bacula immediately terminates but no dump. This is for
46  *                  "obvious" serious errors like daemon already running or
47  *                   cannot open critical file, ... where a dump is not wanted.
48  *  M_TERM        Bacula daemon shutting down because of request (SIGTERM).
49  *
50  * The remaining apply to Jobs rather than the daemon.
51  *
52  *  M_FATAL       Bacula detected a fatal Job error. The Job will be killed,
53  *                  but Bacula continues running.
54  *  M_ERROR       Bacula detected a Job error. The Job will continue running
55  *                  but the termination status will be error.
56  *  M_WARNING     Job warning message.
57  *  M_INFO        Job information message.
58  *
59  *  M_RESTORED    An ls -l of each restored file.
60  *
61  *  M_SECURITY    For security viloations. This is equivalent to FATAL.
62  *                (note, this is currently being implemented in 1.33).
63  *
64  *  M_ALERT       For Tape Alert messages.
65  *
66  */
67
68 enum {
69    /* Keep M_ABORT=1 for dlist.h */
70    M_ABORT = 1,                       /* MUST abort immediately */
71    M_DEBUG,                           /* debug message */
72    M_FATAL,                           /* Fatal error, stopping job */
73    M_ERROR,                           /* Error, but recoverable */
74    M_WARNING,                         /* Warning message */
75    M_INFO,                            /* Informational message */
76    M_SAVED,                           /* Info on saved file */
77    M_NOTSAVED,                        /* Info on notsaved file */
78    M_SKIPPED,                         /* File skipped during backup by option setting */
79    M_MOUNT,                           /* Mount requests */
80    M_ERROR_TERM,                      /* Error termination request (no dump) */
81    M_TERM,                            /* Terminating daemon normally */
82    M_RESTORED,                        /* ls -l of restored files */
83    M_SECURITY,                        /* security violation */
84    M_ALERT                            /* tape alert messages */
85 };
86
87 #define M_MAX      M_ALERT            /* keep this updated ! */
88
89 /* Define message destination structure */
90 /* *** FIXME **** where should be extended to handle multiple values */
91 typedef struct s_dest {
92    struct s_dest *next;
93    int dest_code;                     /* destination (one of the MD_ codes) */
94    int max_len;                       /* max mail line length */
95    FILE *fd;                          /* file descriptor */
96    char msg_types[nbytes_for_bits(M_MAX+1)]; /* message type mask */
97    char *where;                       /* filename/program name */
98    char *mail_cmd;                    /* mail command */
99    POOLMEM *mail_filename;            /* unique mail filename */
100 } DEST;
101
102 /* Message Destination values for dest field of DEST */
103 enum {
104    MD_SYSLOG = 1,                     /* send msg to syslog */
105    MD_MAIL,                           /* email group of messages */
106    MD_FILE,                           /* write messages to a file */
107    MD_APPEND,                         /* append messages to a file */
108    MD_STDOUT,                         /* print messages */
109    MD_STDERR,                         /* print messages to stderr */
110    MD_DIRECTOR,                       /* send message to the Director */
111    MD_OPERATOR,                       /* email a single message to the operator */
112    MD_CONSOLE,                        /* send msg to UserAgent or console */
113    MD_MAIL_ON_ERROR                   /* email messages if job errors */
114 };
115
116 /* Queued message item */
117 struct MQUEUE_ITEM {
118    dlink link;
119    int type;
120    time_t mtime;
121    char msg[1];
122 };
123
124
125 void d_msg(const char *file, int line, int level, const char *fmt,...);
126 void e_msg(const char *file, int line, int type, int level, const char *fmt,...);
127 void Jmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...);
128 void Qmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...);
129 bool get_trace(void);
130
131
132 extern int           DLL_IMP_EXP debug_level;
133 extern int           DLL_IMP_EXP verbose;
134 extern char          DLL_IMP_EXP my_name[];
135 extern const char *  DLL_IMP_EXP working_directory;
136 extern time_t        DLL_IMP_EXP daemon_start_time;
137 extern char                      catalog_db[];
138
139 extern int           DLL_IMP_EXP console_msg_pending;
140 extern FILE *        DLL_IMP_EXP con_fd;                 /* Console file descriptor */
141 extern brwlock_t     DLL_IMP_EXP con_lock;               /* Console lock structure */