3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Jean-Marc Lasgouttes
9 * Full author contact details are available in file CREDITS.
17 #include "support/convert.h"
18 #include "support/lstrings.h"
26 using lyx::support::ascii_lowercase;
27 using lyx::support::bformat;
28 using lyx::support::isStrInt;
43 error_item errorTags[] = {
44 { Debug::NONE, "none", N_("No debugging message")},
45 { Debug::INFO, "info", N_("General information")},
46 { Debug::DEBUG, "debug", N_("Developers' general debug messages")},
47 { Debug::ANY, "any", N_("All debugging messages")}
51 int const numErrorTags = sizeof(errorTags)/sizeof(error_item);
56 lyx_debug_trait::type lyx_debug_trait::value(string const & val)
61 string::size_type st = v.find(',');
62 string tmp(ascii_lowercase(v.substr(0, st)));
67 l |= static_cast<type>(convert<int>(tmp));
69 // Search for an explicit name
70 for (int i = 0 ; i < numErrorTags ; ++i)
71 if (tmp == errorTags[i].name) {
72 l |= errorTags[i].level;
75 if (st == string::npos) break;
82 void lyx_debug_trait::showLevel(ostream & os, lyx_debug_trait::type level)
84 // Show what features are traced
85 for (int i = 0; i < numErrorTags ; ++i) {
86 if (errorTags[i].level != Debug::ANY
87 && errorTags[i].level != Debug::NONE
88 && errorTags[i].level & level) {
89 // avoid _(...) re-entrance problem
90 // FIXME: should we use _() from gettext.h here?
91 lyx::docstring const s = _(errorTags[i].desc);
92 os << lyx::to_utf8(bformat(_("Debugging `%1$s' (%2$s)"),
93 lyx::from_utf8(errorTags[i].name),
102 void lyx_debug_trait::showTags(ostream & os)
104 for (int i = 0; i < numErrorTags ; ++i)
105 os << setw(7) << static_cast<unsigned int>(errorTags[i].level)
106 << setw(10) << errorTags[i].name
107 << " " << lyx::to_utf8(_(errorTags[i].desc)) << '\n';