2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file debug.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
1999-12-13 15:31:52 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "gettext.h"
|
2003-09-09 22:13:45 +00:00
|
|
|
|
|
2005-01-27 21:05:44 +00:00
|
|
|
|
#include "support/convert.h"
|
2001-07-29 17:39:01 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2000-11-14 02:01:57 +00:00
|
|
|
|
|
2003-09-26 14:27:20 +00:00
|
|
|
|
#include <iostream>
|
2002-11-21 18:33:09 +00:00
|
|
|
|
#include <iomanip>
|
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::ascii_lowercase;
|
|
|
|
|
using lyx::support::bformat;
|
|
|
|
|
using lyx::support::isStrInt;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
1999-12-22 14:35:05 +00:00
|
|
|
|
using std::setw;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using std::ostream;
|
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
1999-12-13 15:31:52 +00:00
|
|
|
|
struct error_item {
|
|
|
|
|
Debug::type level;
|
|
|
|
|
char const * name;
|
|
|
|
|
char const * desc;
|
|
|
|
|
};
|
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
|
|
|
|
|
error_item errorTags[] = {
|
2000-11-14 02:01:57 +00:00
|
|
|
|
{ Debug::NONE, "none", N_("No debugging message")},
|
|
|
|
|
{ Debug::INFO, "info", N_("General information")},
|
|
|
|
|
{ Debug::INIT, "init", N_("Program initialisation")},
|
|
|
|
|
{ Debug::KEY, "key", N_("Keyboard events handling")},
|
|
|
|
|
{ Debug::GUI, "gui", N_("GUI handling")},
|
2003-06-24 10:41:22 +00:00
|
|
|
|
{ Debug::PARSER, "parser", N_("Lyxlex grammar parser")},
|
2000-11-14 02:01:57 +00:00
|
|
|
|
{ Debug::LYXRC, "lyxrc", N_("Configuration files reading")},
|
|
|
|
|
{ Debug::KBMAP, "kbmap", N_("Custom keyboard definition")},
|
|
|
|
|
{ Debug::LATEX, "latex", N_("LaTeX generation/execution")},
|
|
|
|
|
{ Debug::MATHED, "mathed", N_("Math editor")},
|
|
|
|
|
{ Debug::FONT, "font", N_("Font handling")},
|
|
|
|
|
{ Debug::TCLASS, "tclass", N_("Textclass files reading")},
|
|
|
|
|
{ Debug::LYXVC, "lyxvc", N_("Version control")},
|
|
|
|
|
{ Debug::LYXSERVER, "lyxserver", N_("External control interface")},
|
|
|
|
|
{ Debug::ROFF, "roff", N_("Keep *roff temporary files")},
|
|
|
|
|
{ Debug::ACTION, "action", N_("User commands")},
|
|
|
|
|
{ Debug::LYXLEX, "lyxlex", N_("The LyX Lexxer")},
|
|
|
|
|
{ Debug::DEPEND, "depend", N_("Dependency information")},
|
|
|
|
|
{ Debug::INSETS, "insets", N_("LyX Insets")},
|
|
|
|
|
{ Debug::FILES, "files", N_("Files used by LyX")},
|
2001-11-09 13:44:48 +00:00
|
|
|
|
{ Debug::WORKAREA, "workarea", N_("Workarea events")},
|
2002-02-16 12:33:19 +00:00
|
|
|
|
{ Debug::INSETTEXT, "insettext", N_("Insettext/tabular messages")},
|
|
|
|
|
{ Debug::GRAPHICS, "graphics", N_("Graphics conversion and loading")},
|
2003-02-08 19:18:01 +00:00
|
|
|
|
{ Debug::CHANGES, "changes", N_("Change tracking")},
|
2003-09-04 17:01:00 +00:00
|
|
|
|
{ Debug::EXTERNAL, "external", N_("External template/inset messages")},
|
2005-07-17 12:39:56 +00:00
|
|
|
|
{ Debug::DEBUG, "debug", N_("Developers' general debug messages")},
|
2001-11-29 12:58:59 +00:00
|
|
|
|
{ Debug::ANY, "any", N_("All debugging messages")}
|
1999-12-13 15:31:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
1999-12-13 21:59:26 +00:00
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
int const numErrorTags = sizeof(errorTags)/sizeof(error_item);
|
|
|
|
|
|
|
|
|
|
} // namespace anon
|
1999-12-13 15:31:52 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-09-26 14:27:20 +00:00
|
|
|
|
lyx_debug_trait::type lyx_debug_trait::value(string const & val)
|
1999-12-13 15:31:52 +00:00
|
|
|
|
{
|
|
|
|
|
type l = Debug::NONE;
|
|
|
|
|
string v(val);
|
|
|
|
|
while (!v.empty()) {
|
2005-01-27 21:05:44 +00:00
|
|
|
|
string::size_type const st = v.find(',');
|
|
|
|
|
string const tmp(ascii_lowercase(v.substr(0, st)));
|
2000-01-25 12:35:27 +00:00
|
|
|
|
if (tmp.empty())
|
1999-12-13 15:31:52 +00:00
|
|
|
|
break;
|
|
|
|
|
// Is it a number?
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (isStrInt(tmp))
|
2005-01-27 21:05:44 +00:00
|
|
|
|
l |= static_cast<type>(convert<int>(tmp));
|
1999-12-13 15:31:52 +00:00
|
|
|
|
else
|
|
|
|
|
// Search for an explicit name
|
2002-03-21 17:27:08 +00:00
|
|
|
|
for (int i = 0 ; i < numErrorTags ; ++i)
|
1999-12-13 15:31:52 +00:00
|
|
|
|
if (tmp == errorTags[i].name) {
|
|
|
|
|
l |= errorTags[i].level;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (st == string::npos) break;
|
|
|
|
|
v.erase(0, st + 1);
|
|
|
|
|
}
|
|
|
|
|
return l;
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-13 21:59:26 +00:00
|
|
|
|
|
2003-09-26 14:27:20 +00:00
|
|
|
|
void lyx_debug_trait::showLevel(ostream & os, lyx_debug_trait::type level)
|
1999-12-13 15:31:52 +00:00
|
|
|
|
{
|
|
|
|
|
// Show what features are traced
|
2003-05-13 09:48:57 +00:00
|
|
|
|
for (int i = 0; i < numErrorTags ; ++i) {
|
1999-12-13 15:31:52 +00:00
|
|
|
|
if (errorTags[i].level != Debug::ANY
|
|
|
|
|
&& errorTags[i].level != Debug::NONE
|
2002-11-24 15:20:31 +00:00
|
|
|
|
&& errorTags[i].level & level) {
|
2003-05-16 14:35:15 +00:00
|
|
|
|
// avoid _(...) re-entrance problem
|
2003-06-28 01:23:11 +00:00
|
|
|
|
string const s = _(errorTags[i].desc);
|
2003-05-13 09:48:57 +00:00
|
|
|
|
os << bformat(_("Debugging `%1$s' (%2$s)"),
|
2004-04-29 15:25:56 +00:00
|
|
|
|
errorTags[i].name, s)
|
|
|
|
|
<< '\n';
|
2002-11-24 15:20:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-04-29 15:25:56 +00:00
|
|
|
|
os.flush();
|
1999-12-13 15:31:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-26 14:27:20 +00:00
|
|
|
|
void lyx_debug_trait::showTags(ostream & os)
|
1999-12-13 15:31:52 +00:00
|
|
|
|
{
|
2003-05-13 09:48:57 +00:00
|
|
|
|
for (int i = 0; i < numErrorTags ; ++i)
|
2004-06-18 13:31:55 +00:00
|
|
|
|
os << setw(7) << static_cast<unsigned int>(errorTags[i].level)
|
1999-12-22 14:35:05 +00:00
|
|
|
|
<< setw(10) << errorTags[i].name
|
2000-11-14 02:01:57 +00:00
|
|
|
|
<< " " << _(errorTags[i].desc) << '\n';
|
1999-12-13 21:59:26 +00:00
|
|
|
|
os.flush();
|
1999-12-13 15:31:52 +00:00
|
|
|
|
}
|
2003-09-26 14:27:20 +00:00
|
|
|
|
|
2003-11-01 13:03:03 +00:00
|
|
|
|
LyXErr lyxerr;
|