5 * This file is part of LyX, the document processor.
6 * Licence details can be found in the file COPYING.
8 * \author Lars Gullik Bjønnes
9 * \author Jean-Marc Lasgouttes
12 * Full author contact details are available in file CREDITS.
18 #include "support/strfwd.h"
24 template<typename CharT, typename Traits> class basic_streambuf;
25 typedef basic_streambuf<char, char_traits<char> > streambuf;
32 /// This is all the different debug levels that we have.
47 PARSER = (1 << 4), // 16
49 LYXRC = (1 << 5), // 32
51 KBMAP = (1 << 6), // 64
53 LATEX = (1 << 7), // 128
55 MATHED = (1 << 8), // 256 // Alejandro, please use this.
57 FONT = (1 << 9), // 512
59 TCLASS = (1 << 10), // 1024
61 LYXVC = (1 << 11), // 2048
63 LYXSERVER = (1 << 12), // 4096
65 UNDO = (1 << 13), // 8192
67 ACTION = (1 << 14), // 16384
79 INSETTEXT = (1 << 20),
89 SCROLLING = (1 << 25),
97 SELECTION = (1 << 29),
106 /// Return number of levels
109 /// A function to convert debug level string names numerical values
110 Type value(std::string const & val);
112 /// A function to convert index of level to their numerical value
115 /// Return description of level
116 std::string const description(Type val);
118 /// Return name of level
119 std::string const name(Type val);
121 /// Display the tags and descriptions of the current debug level
122 void showLevel(std::ostream & os, Type level);
124 /// Show all the possible tags that can be used for debugging
125 void showTags(std::ostream & os);
131 inline void operator|=(Debug::Type & d1, Debug::Type d2)
133 d1 = static_cast<Debug::Type>(d1 | d2);
140 LyXErr(): enabled_(true), second_enabled_(false) {}
142 /// Disable the stream completely
144 /// Enable the stream after a possible call of disable()
151 std::ostream & stream() { return *stream_; }
153 operator std::ostream &() { return *stream_; }
155 void setStream(std::ostream & os) { stream_ = &os; }
156 /// Is the stream enabled ?
157 bool enabled() const { return enabled_; }
159 /// Returns second stream
160 std::ostream & secondStream() { return *second_stream_; };
161 /// Sets second stream
162 void setSecondStream(std::ostream * os)
163 { second_enabled_ = (second_stream_ = os); }
164 /// Is the second stream is enabled?
165 bool secondEnabled() { return second_enabled_; }
167 /// Sets the debug level
168 void setLevel(Debug::Type t) { dt_ = t; }
169 /// Returns the current debug level
170 Debug::Type level() const { return dt_; }
171 /// Returns true if t is part of the current debug level
172 bool debugging(Debug::Type t = Debug::ANY) const;
175 /// The current debug level
178 std::ostream * stream_;
179 /// Is the stream enabled?
181 /// Next stream for output duplication
182 std::ostream * second_stream_;
183 /// Is the second stream enabled?
184 bool second_enabled_;
187 namespace support { class FileName; }
189 LyXErr & operator<<(LyXErr &, void const *);
190 LyXErr & operator<<(LyXErr &, char const *);
191 LyXErr & operator<<(LyXErr &, char);
192 LyXErr & operator<<(LyXErr &, int);
193 LyXErr & operator<<(LyXErr &, unsigned int);
194 LyXErr & operator<<(LyXErr &, long);
195 LyXErr & operator<<(LyXErr &, unsigned long);
196 LyXErr & operator<<(LyXErr &, double);
197 LyXErr & operator<<(LyXErr &, std::string const &);
198 LyXErr & operator<<(LyXErr &, docstring const &);
199 LyXErr & operator<<(LyXErr &, support::FileName const &);
200 LyXErr & operator<<(LyXErr &, std::ostream &(*)(std::ostream &));
201 LyXErr & operator<<(LyXErr &, std::ios_base &(*)(std::ios_base &));
203 extern LyXErr lyxerr;
207 #if USE_BOOST_CURRENT_FUNCTION
208 # include <boost/current_function.hpp>
209 # define CURRENT_POSITION BOOST_CURRENT_FUNCTION ": "
211 # define CURRENT_POSITION __FILE__ << "(" << __LINE__ << "): "
214 #define LYXERR(type, msg) \
216 if (!lyx::lyxerr.debugging(type)) {} \
217 else { lyx::lyxerr << CURRENT_POSITION << msg; lyx::lyxerr.endl(); } \
220 #define LYXERR0(msg) \
222 lyx::lyxerr << CURRENT_POSITION << msg; lyx::lyxerr.endl(); \