1 | /* Copyright © 2005-2007 Roger Leigh <rleigh@debian.org> |
---|
2 | * |
---|
3 | * schroot is free software: you can redistribute it and/or modify it |
---|
4 | * under the terms of the GNU General Public License as published by |
---|
5 | * the Free Software Foundation, either version 3 of the License, or |
---|
6 | * (at your option) any later version. |
---|
7 | * |
---|
8 | * schroot is distributed in the hope that it will be useful, but |
---|
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
11 | * General Public License for more details. |
---|
12 | * |
---|
13 | * You should have received a copy of the GNU General Public License |
---|
14 | * along with this program. If not, see |
---|
15 | * <http://www.gnu.org/licenses/>. |
---|
16 | * |
---|
17 | *********************************************************************/ |
---|
18 | |
---|
19 | #ifndef SBUILD_LOG_H |
---|
20 | #define SBUILD_LOG_H |
---|
21 | |
---|
22 | #include <ostream> |
---|
23 | |
---|
24 | namespace sbuild |
---|
25 | { |
---|
26 | |
---|
27 | /// Debugging level. |
---|
28 | enum debug_level |
---|
29 | { |
---|
30 | DEBUG_NONE = -1, ///< No debugging. |
---|
31 | DEBUG_NOTICE = 1, ///< Notification messages. |
---|
32 | DEBUG_INFO = 2, ///< Informational messages. |
---|
33 | DEBUG_WARNING = 3, ///< Warning messages. |
---|
34 | DEBUG_CRITICAL = 4 ///< Critical messages. |
---|
35 | }; |
---|
36 | |
---|
37 | /** |
---|
38 | * Log an informational message. |
---|
39 | * |
---|
40 | * @returns an ostream. |
---|
41 | */ |
---|
42 | std::ostream& |
---|
43 | log_info (); |
---|
44 | |
---|
45 | /** |
---|
46 | * Log a warning message. |
---|
47 | * |
---|
48 | * @returns an ostream. |
---|
49 | */ |
---|
50 | std::ostream& |
---|
51 | log_warning (); |
---|
52 | |
---|
53 | /** |
---|
54 | * Log an error message. |
---|
55 | * |
---|
56 | * @returns an ostream. |
---|
57 | */ |
---|
58 | std::ostream& |
---|
59 | log_error (); |
---|
60 | |
---|
61 | /** |
---|
62 | * Log a debug message. |
---|
63 | * |
---|
64 | * @param level the debug level of the message being logged. |
---|
65 | * @returns an ostream. This will be a valid stream if level is |
---|
66 | * greater or equal to debug_level, or else a null stream will be |
---|
67 | * returned, resulting in no output. |
---|
68 | */ |
---|
69 | std::ostream& |
---|
70 | log_debug (debug_level level); |
---|
71 | |
---|
72 | /** |
---|
73 | * Log an informational message to the Controlling TTY. |
---|
74 | * |
---|
75 | * @returns an ostream. |
---|
76 | */ |
---|
77 | std::ostream& |
---|
78 | log_ctty_info (); |
---|
79 | |
---|
80 | /** |
---|
81 | * Log a warning message to the Controlling TTY. |
---|
82 | * |
---|
83 | * @returns an ostream. |
---|
84 | */ |
---|
85 | std::ostream& |
---|
86 | log_ctty_warning (); |
---|
87 | |
---|
88 | /** |
---|
89 | * Log an error message to the Controlling TTY. |
---|
90 | * |
---|
91 | * @returns an ostream. |
---|
92 | */ |
---|
93 | std::ostream& |
---|
94 | log_ctty_error (); |
---|
95 | |
---|
96 | /** |
---|
97 | * Log an exception as a warning. |
---|
98 | * |
---|
99 | * @param e the exception to log. |
---|
100 | */ |
---|
101 | void |
---|
102 | log_exception_warning (std::exception const& e); |
---|
103 | |
---|
104 | /** |
---|
105 | * Log an exception as an error. |
---|
106 | * |
---|
107 | * @param e the exception to log. |
---|
108 | */ |
---|
109 | void |
---|
110 | log_exception_error (std::exception const& e); |
---|
111 | |
---|
112 | /** |
---|
113 | * Log an exception as a warning to the Controlling TTY. |
---|
114 | * |
---|
115 | * @param e the exception to log. |
---|
116 | */ |
---|
117 | void |
---|
118 | log_ctty_exception_warning (std::exception const& e); |
---|
119 | |
---|
120 | /** |
---|
121 | * Log an exception as an error to the Controlling TTY. |
---|
122 | * |
---|
123 | * @param e the exception to log. |
---|
124 | */ |
---|
125 | void |
---|
126 | log_ctty_exception_error (std::exception const& e); |
---|
127 | |
---|
128 | /** |
---|
129 | * Log an unknown exception as an error. |
---|
130 | */ |
---|
131 | void |
---|
132 | log_unknown_exception_error (); |
---|
133 | |
---|
134 | /// The debugging level in use. |
---|
135 | extern debug_level debug_log_level; |
---|
136 | |
---|
137 | } |
---|
138 | |
---|
139 | #endif /* SBUILD_LOG_H */ |
---|
140 | |
---|
141 | /* |
---|
142 | * Local Variables: |
---|
143 | * mode:C++ |
---|
144 | * End: |
---|
145 | */ |
---|