X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Fdebug.h;h=d636e4c5c32a3c4d1487a82a3a803e47be86cfd4;hb=f8cc30a1f20de97425d17fc1779041d0f963f74a;hp=ac22450384ae233bb6f2d5d55834842f7dbc75e4;hpb=2506e0d643a6030d22a7990d47306837e51cb0d2;p=lyx.git diff --git a/src/support/debug.h b/src/support/debug.h index ac22450384..d636e4c5c3 100644 --- a/src/support/debug.h +++ b/src/support/debug.h @@ -2,15 +2,12 @@ /** * \file debug.h * - * FIXME: It would be nice if, in lyx::use_gui mode, instead of - * outputting to the console, we would pipe all messages onto a file - * and visualise the contents dynamically in a Qt window if needed. - * * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bjønnes * \author Jean-Marc Lasgouttes + * \author Pavel Sanda * * Full author contact details are available in file CREDITS. */ @@ -20,7 +17,6 @@ #include "support/strfwd.h" - namespace std { class ios_base; @@ -66,7 +62,7 @@ namespace Debug { /// LYXSERVER = (1 << 12), // 4096 /// - ROFF = (1 << 13), // 8192 + UNDO = (1 << 13), // 8192 /// ACTION = (1 << 14), // 16384 /// @@ -90,24 +86,45 @@ namespace Debug { /// PAINTING = (1 << 24), /// + SCROLLING = (1 << 25), + /// + MACROS = (1 << 26), + /// rtl-related + RTL = (1 << 27), + /// locale related + LOCALE = (1 << 28), + /// selection + SELECTION = (1 << 29), + /// Find and Replace + FIND = (1 << 30), + /// DEBUG = (1 << 31), /// ANY = 0xffffffff }; - /** A function to convert symbolic string names on debug levels - to their numerical value. - */ + /// Return number of levels + int levelCount(); + + /// A function to convert debug level string names numerical values Type value(std::string const & val); - /** Display the tags and descriptions of the current debug level - of ds - */ + /// A function to convert index of level to their numerical value + Type value(int val); + + /// Return description of level + std::string const description(Type val); + + /// Return name of level + std::string const name(Type val); + + /// Display the tags and descriptions of the current debug level void showLevel(std::ostream & os, Type level); - /** show all the possible tags that can be used for debugging */ + /// Show all the possible tags that can be used for debugging void showTags(std::ostream & os); + } // namespace Debug @@ -120,31 +137,51 @@ inline void operator|=(Debug::Type & d1, Debug::Type d2) class LyXErr { public: + LyXErr(): enabled_(true), second_enabled_(false) {} + /// Disable the stream completely void disable(); /// Enable the stream after a possible call of disable() void enable(); - /// Returns true if t is part of the current debug level. - bool debugging(Debug::Type t = Debug::ANY) const; + /// Ends output void endl(); - /// Sets stream - void setStream(std::ostream & os) { stream_ = &os; } - /// Sets stream + + /// Returns stream std::ostream & stream() { return *stream_; } - /// Sets the debug level to t. - void level(Debug::Type t) { dt = t; } - /// Returns the current debug level. - Debug::Type level() const { return dt; } /// Returns stream operator std::ostream &() { return *stream_; } + /// Sets stream + void setStream(std::ostream & os) { stream_ = &os; } + /// Is the stream enabled ? + bool enabled() const { return enabled_; } + + /// Returns second stream + std::ostream & secondStream() { return *second_stream_; }; + /// Sets second stream + void setSecondStream(std::ostream * os) + { second_enabled_ = (second_stream_ = os); } + /// Is the second stream is enabled? + bool secondEnabled() { return second_enabled_; } + + /// Sets the debug level + void setLevel(Debug::Type t) { dt_ = t; } + /// Returns the current debug level + Debug::Type level() const { return dt_; } + /// Returns true if t is part of the current debug level + bool debugging(Debug::Type t = Debug::ANY) const; + private: /// The current debug level - Debug::Type dt; - /// Is the stream enabled? - bool enabled_; + Debug::Type dt_; /// The real stream std::ostream * stream_; + /// Is the stream enabled? + bool enabled_; + /// Next stream for output duplication + std::ostream * second_stream_; + /// Is the second stream enabled? + bool second_enabled_; }; namespace support { class FileName; } @@ -167,27 +204,23 @@ extern LyXErr lyxerr; } // namespace lyx -// stolen from boost/current_function.hpp -#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) -# define CURRENT_FUNCTION __PRETTY_FUNCTION__ -#elif defined(__FUNCSIG__) -# define CURRENT_FUNCTION __FUNCSIG__ -#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500)) -# define CURRENT_FUNCTION __FUNCTION__ -#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) -# define CURRENT_FUNCTION __FUNC__ -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) -# define CURRENT_FUNCTION __func__ +#if USE_BOOST_CURRENT_FUNCTION +# include +# define CURRENT_POSITION BOOST_CURRENT_FUNCTION ": " #else -# define CURRENT_FUNCTION "(unknown)" +# define CURRENT_POSITION __FILE__ << "(" << __LINE__ << "): " #endif #define LYXERR(type, msg) \ do { \ if (!lyx::lyxerr.debugging(type)) {} \ - else { lyx::lyxerr << CURRENT_FUNCTION <<": "<