// -*- C++ -*-
+/**
+ * \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 Jean-Marc Lasgouttes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
#ifndef LYXDEBUG_H
#define LYXDEBUG_H
-#include "LString.h"
+#include "support/debugstream.h"
+#include "support/docstring.h"
+
+
+namespace lyx {
/** Ideally this should have been a namespace, but since we try to be
- compilable on older C++ compilators too, we use a struct instead.
- This is all the different debug levels that we have.
-*/
-struct Debug {
+ * compilable on older C++ compilators too, we use a struct instead.
+ * This is all the different debug levels that we have.
+ */
+class lyx_debug_trait {
+public:
///
enum type {
///
///
KEY = (1 << 2), // 4
///
- TOOLBAR = (1 << 3), // 8
+ GUI = (1 << 3), // 8
///
PARSER = (1 << 4), // 16
///
///
LYXSERVER = (1 << 12), // 4096
///
- ROFF = (1 << 13)
+ ROFF = (1 << 13), // 8192
+ ///
+ ACTION = (1 << 14), // 16384
+ ///
+ LYXLEX = (1 << 15),
+ ///
+ DEPEND = (1 << 16),
+ ///
+ INSETS = (1 << 17),
+ ///
+ FILES = (1 << 18),
+ ///
+ WORKAREA = (1 << 19),
+ ///
+ INSETTEXT = (1 << 20),
+ ///
+ GRAPHICS = (1 << 21),
+ /// change tracking
+ CHANGES = (1 << 22),
+ ///
+ EXTERNAL = (1 << 23),
+ ///
+ PAINTING = (1 << 24),
+ ///
+ DEBUG = (1 << 31),
+ ///
+ ANY = 0xffffffff
};
- ///
- static const type ANY = type(INFO | INIT | KEY | TOOLBAR |
- PARSER | LYXRC | KBMAP | LATEX |
- MATHED | FONT | TCLASS | LYXVC |
- LYXSERVER | ROFF);
+
+ static bool match(type a, type b) {
+ return (a & b);
+ }
/** A function to convert symbolic string names on debug levels
to their numerical value.
*/
- static Debug::type value(string const & val) {
- int l = Debug::NONE;
- string v(val);
- while (!v.empty()) {
- string::size_type st = v.find(',');
- string tmp(v.substr(0, st));
- if (tmp.empty()) break;
- if (val == "NONE") l |= Debug::NONE;
- else if (val == "INFO") l |= Debug::INFO;
- else if (val == "INIT") l |= Debug::INIT;
- else if (val == "KEY") l |= Debug::KEY;
- else if (val == "TOOLBAR") l |= Debug::TOOLBAR;
- else if (val == "PARSER") l |= Debug::PARSER;
- else if (val == "LYXRC") l |= Debug::LYXRC;
- else if (val == "KBMAP") l |= Debug::KBMAP;
- else if (val == "LATEX") l |= Debug::LATEX;
- else if (val == "MATHED") l |= Debug::MATHED;
- else if (val == "FONT") l |= Debug::FONT;
- else if (val == "TCLASS") l |= Debug::TCLASS;
- else if (val == "LYXVC") l |= Debug::LYXVC;
- else if (val == "LYXSERVER") l |= Debug::LYXSERVER;
- else if (val == "ROFF") l |= Debug::ROFF;
- else break; // unknown string
- if (st == string::npos) break;
- v.erase(0, st + 1);
- }
- return Debug::type(l);
- }
+ static type value(std::string const & val);
+
+ /** Display the tags and descriptions of the current debug level
+ of ds
+ */
+ static void showLevel(std::ostream & o, type level);
+
+ /** show all the possible tags that can be used for debugging */
+ static void showTags(std::ostream & o);
+
};
-///
-ostream & operator<<(ostream & o, Debug::type t);
-#include "support/DebugStream.h"
-extern DebugStream lyxerr;
+inline
+void operator|=(lyx_debug_trait::type & d1, lyx_debug_trait::type d2)
+{
+ d1 = static_cast<lyx_debug_trait::type>(d1 | d2);
+}
-#endif
+typedef basic_debugstream<lyx_debug_trait> LyXErr;
+typedef LyXErr::debug Debug;
+
+extern LyXErr lyxerr;
+
+} // namespace lyx
+#define LYXERR(type) if (!lyx::lyxerr.debugging(type)) ; else lyx::lyxerr
+
+
+#endif