]> git.lyx.org Git - lyx.git/blob - src/debug.C
Fix configure bug with gettext
[lyx.git] / src / debug.C
1 /* This file is part of
2 * ====================================================== 
3
4 *           LyX, The Document Processor
5 *        
6 *           Copyright 1999-2000 The LyX Team.
7 *
8 * ====================================================== */
9
10 #ifdef __GNUG__
11 #pragma implementation
12 #endif
13
14 #include <config.h>
15 #include "debug.h"
16
17 #include <iomanip>
18 using std::setw;
19
20 struct error_item {
21         Debug::type level;
22         char const * name;
23         char const * desc;
24 };
25
26 static error_item errorTags[] = {
27         { Debug::INFO,          "info",         "General information"},
28         { Debug::INIT,          "init",         "Program initialisation"},
29         { Debug::KEY,           "key",          "Keyboard events handling"},
30         { Debug::TOOLBAR,       "toolbar",      "Toolbar handling"},
31         { Debug::PARSER,        "parser",       "Lyxlex grammer parser"},
32         { Debug::LYXRC,         "lyxrc",        "Configuration files reading"},
33         { Debug::KBMAP,         "kbmap",        "Custom keyboard definition"},
34         { Debug::LATEX,         "latex",        "LaTeX generation/execution"},
35         { Debug::DEPEND,        "depend",       "Dependency information"},
36         { Debug::MATHED,        "mathed",       "Math editor"},
37         { Debug::FONT,          "font",         "Font handling"},
38         { Debug::TCLASS,        "tclass",       "Textclass files reading"},
39         { Debug::LYXVC,         "lyxvc",        "Version control"},
40         { Debug::LYXSERVER,     "lyxserver",    "External control interface"},
41         { Debug::ROFF,          "roff",         "Keep *roff temporary files"},
42         { Debug::ACTION,        "action",       "User commands"},
43         { Debug::LYXLEX,        "lyxlex",       "The LyX Lexxer"},
44         { Debug::NONE,          "none",         "No debugging message"},
45         { Debug::ANY,           "any",          "All debugging messages"}
46 };
47
48
49 static const int numErrorTags = sizeof(errorTags)/sizeof(error_item);
50
51
52 Debug::type Debug::value(string const & val) 
53 {
54         type l = Debug::NONE;
55         string v(val);
56         while (!v.empty()) {
57                 string::size_type st = v.find(',');
58                 string tmp(lowercase(v.substr(0, st)));
59                 if (tmp.empty())
60                         break;
61                 // Is it a number?
62                 if (isStrInt(tmp)) 
63                         l |= static_cast<type>(strToInt(tmp));
64                 else
65                 // Search for an explicit name
66                 for (int i = 0 ; i < numErrorTags ; ++i) 
67                         if (tmp == errorTags[i].name) {
68                                 l |= errorTags[i].level;
69                                 break;
70                         }
71                 if (st == string::npos) break;
72                 v.erase(0, st + 1);
73         }
74         return l;
75 }
76
77
78 void Debug::showLevel(ostream & o, Debug::type level)
79 {
80         // Show what features are traced
81         for (int i = 0 ; i < numErrorTags ; ++i)
82                 if (errorTags[i].level != Debug::ANY
83                     && errorTags[i].level != Debug::NONE
84                     && errorTags[i].level & level)
85                         o << "Debugging `" << errorTags[i].name
86                           << "' (" << errorTags[i].desc << ')' << endl;
87 }
88
89
90 void Debug::showTags(ostream & os) 
91 {
92         for (int i = 0 ; i < numErrorTags ; ++i)
93                 os << setw(5) << errorTags[i].level
94                    << setw(10) << errorTags[i].name
95                    << "  " << errorTags[i].desc << '\n';
96         os.flush();
97 }