1999-12-13 15:31:52 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright 1999-2000 The LyX Team.
|
1999-12-13 15:31:52 +00:00
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include "debug.h"
|
|
|
|
|
1999-12-22 14:35:05 +00:00
|
|
|
#include <iomanip>
|
2000-03-28 02:18:55 +00:00
|
|
|
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::ostream;
|
1999-12-22 14:35:05 +00:00
|
|
|
using std::setw;
|
2000-03-28 02:18:55 +00:00
|
|
|
using std::endl;
|
1999-12-22 14:35:05 +00:00
|
|
|
|
1999-12-13 15:31:52 +00:00
|
|
|
struct error_item {
|
|
|
|
Debug::type level;
|
|
|
|
char const * name;
|
|
|
|
char const * desc;
|
|
|
|
};
|
|
|
|
|
|
|
|
static error_item errorTags[] = {
|
2000-05-17 13:40:40 +00:00
|
|
|
{ Debug::NONE, "none", "No debugging message"},
|
1999-12-13 15:31:52 +00:00
|
|
|
{ Debug::INFO, "info", "General information"},
|
|
|
|
{ Debug::INIT, "init", "Program initialisation"},
|
|
|
|
{ Debug::KEY, "key", "Keyboard events handling"},
|
|
|
|
{ Debug::TOOLBAR, "toolbar", "Toolbar handling"},
|
|
|
|
{ Debug::PARSER, "parser", "Lyxlex grammer parser"},
|
|
|
|
{ Debug::LYXRC, "lyxrc", "Configuration files reading"},
|
|
|
|
{ Debug::KBMAP, "kbmap", "Custom keyboard definition"},
|
|
|
|
{ Debug::LATEX, "latex", "LaTeX generation/execution"},
|
|
|
|
{ Debug::MATHED, "mathed", "Math editor"},
|
|
|
|
{ Debug::FONT, "font", "Font handling"},
|
|
|
|
{ Debug::TCLASS, "tclass", "Textclass files reading"},
|
|
|
|
{ Debug::LYXVC, "lyxvc", "Version control"},
|
|
|
|
{ Debug::LYXSERVER, "lyxserver", "External control interface"},
|
|
|
|
{ Debug::ROFF, "roff", "Keep *roff temporary files"},
|
|
|
|
{ Debug::ACTION, "action", "User commands"},
|
2000-01-06 02:44:26 +00:00
|
|
|
{ Debug::LYXLEX, "lyxlex", "The LyX Lexxer"},
|
2000-05-17 13:40:40 +00:00
|
|
|
{ Debug::DEPEND, "depend", "Dependency information"},
|
2000-04-19 14:42:19 +00:00
|
|
|
{ Debug::INSETS, "insets", "LyX Insets"},
|
1999-12-13 15:31:52 +00:00
|
|
|
{ Debug::ANY, "any", "All debugging messages"}
|
|
|
|
};
|
|
|
|
|
1999-12-13 21:59:26 +00:00
|
|
|
|
1999-12-13 15:31:52 +00:00
|
|
|
static const int numErrorTags = sizeof(errorTags)/sizeof(error_item);
|
|
|
|
|
1999-12-13 21:59:26 +00:00
|
|
|
|
1999-12-13 15:31:52 +00:00
|
|
|
Debug::type Debug::value(string const & val)
|
|
|
|
{
|
|
|
|
type l = Debug::NONE;
|
|
|
|
string v(val);
|
|
|
|
while (!v.empty()) {
|
|
|
|
string::size_type st = v.find(',');
|
|
|
|
string tmp(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?
|
|
|
|
if (isStrInt(tmp))
|
|
|
|
l |= static_cast<type>(strToInt(tmp));
|
|
|
|
else
|
|
|
|
// Search for an explicit name
|
1999-12-13 21:59:26 +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
|
|
|
|
|
|
|
void Debug::showLevel(ostream & o, Debug::type level)
|
1999-12-13 15:31:52 +00:00
|
|
|
{
|
|
|
|
// Show what features are traced
|
|
|
|
for (int i = 0 ; i < numErrorTags ; ++i)
|
|
|
|
if (errorTags[i].level != Debug::ANY
|
|
|
|
&& errorTags[i].level != Debug::NONE
|
|
|
|
&& errorTags[i].level & level)
|
|
|
|
o << "Debugging `" << errorTags[i].name
|
|
|
|
<< "' (" << errorTags[i].desc << ')' << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-13 21:59:26 +00:00
|
|
|
void Debug::showTags(ostream & os)
|
1999-12-13 15:31:52 +00:00
|
|
|
{
|
|
|
|
for (int i = 0 ; i < numErrorTags ; ++i)
|
2000-05-17 13:40:40 +00:00
|
|
|
os << setw(7) << errorTags[i].level
|
1999-12-22 14:35:05 +00:00
|
|
|
<< setw(10) << errorTags[i].name
|
1999-12-13 21:59:26 +00:00
|
|
|
<< " " << errorTags[i].desc << '\n';
|
|
|
|
os.flush();
|
1999-12-13 15:31:52 +00:00
|
|
|
}
|