5 * FIXME: It would be nice if, in lyx::use_gui mode, instead of
6 * outputting to the console, we would pipe all messages onto a file
7 * and visualise the contents dynamically in a Qt window if needed.
9 * This file is part of LyX, the document processor.
10 * Licence details can be found in the file COPYING.
12 * \author Lars Gullik Bjønnes
13 * \author Jean-Marc Lasgouttes
15 * Full author contact details are available in file CREDITS.
21 #include "support/strfwd.h"
28 template<typename CharT, typename Traits> class basic_streambuf;
29 typedef basic_streambuf<char, char_traits<char> > streambuf;
36 /// This is all the different debug levels that we have.
51 PARSER = (1 << 4), // 16
53 LYXRC = (1 << 5), // 32
55 KBMAP = (1 << 6), // 64
57 LATEX = (1 << 7), // 128
59 MATHED = (1 << 8), // 256 // Alejandro, please use this.
61 FONT = (1 << 9), // 512
63 TCLASS = (1 << 10), // 1024
65 LYXVC = (1 << 11), // 2048
67 LYXSERVER = (1 << 12), // 4096
69 UNDO = (1 << 13), // 8192
71 ACTION = (1 << 14), // 16384
83 INSETTEXT = (1 << 20),
93 SCROLLING = (1 << 25),
101 SELECTION = (1 << 29),
110 /** A function to convert symbolic string names on debug levels
111 to their numerical value.
113 Type value(std::string const & val);
115 /** Display the tags and descriptions of the current debug level
118 void showLevel(std::ostream & os, Type level);
120 /** show all the possible tags that can be used for debugging */
121 void showTags(std::ostream & os);
126 inline void operator|=(Debug::Type & d1, Debug::Type d2)
128 d1 = static_cast<Debug::Type>(d1 | d2);
135 LyXErr(): enabled_(true) {}
136 /// Disable the stream completely
138 /// Enable the stream after a possible call of disable()
141 bool enabled() const { return enabled_; }
142 /// Returns true if t is part of the current debug level.
143 bool debugging(Debug::Type t = Debug::ANY) const;
147 void setStream(std::ostream & os) { stream_ = &os; }
149 std::ostream & stream() { return *stream_; }
150 /// Sets the debug level to t.
151 void level(Debug::Type t) { dt = t; }
152 /// Returns the current debug level.
153 Debug::Type level() const { return dt; }
155 operator std::ostream &() { return *stream_; }
157 /// The current debug level
159 /// Is the stream enabled?
162 std::ostream * stream_;
165 namespace support { class FileName; }
167 LyXErr & operator<<(LyXErr &, void const *);
168 LyXErr & operator<<(LyXErr &, char const *);
169 LyXErr & operator<<(LyXErr &, char);
170 LyXErr & operator<<(LyXErr &, int);
171 LyXErr & operator<<(LyXErr &, unsigned int);
172 LyXErr & operator<<(LyXErr &, long);
173 LyXErr & operator<<(LyXErr &, unsigned long);
174 LyXErr & operator<<(LyXErr &, double);
175 LyXErr & operator<<(LyXErr &, std::string const &);
176 LyXErr & operator<<(LyXErr &, docstring const &);
177 LyXErr & operator<<(LyXErr &, support::FileName const &);
178 LyXErr & operator<<(LyXErr &, std::ostream &(*)(std::ostream &));
179 LyXErr & operator<<(LyXErr &, std::ios_base &(*)(std::ios_base &));
181 extern LyXErr lyxerr;
185 #if USE_BOOST_CURRENT_FUNCTION
186 # include <boost/current_function.hpp>
187 # define CURRENT_POSITION BOOST_CURRENT_FUNCTION ": "
189 # define CURRENT_POSITION __FILE__ << "(" << __LINE__ << "): "
192 #define LYXERR(type, msg) \
194 if (!lyx::lyxerr.debugging(type)) {} \
195 else { lyx::lyxerr << CURRENT_POSITION << msg; lyx::lyxerr.endl(); } \
198 #define LYXERR0(msg) \
200 lyx::lyxerr << CURRENT_POSITION << msg; lyx::lyxerr.endl(); \