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"
23 using lyx::support::ascii_lowercase;
24 using lyx::support::bformat;
25 using lyx::support::isStrInt;
40 error_item errorTags[] = {
41 { Debug::NONE, "none", N_("No debugging message")},
42 { Debug::INFO, "info", N_("General information")},
43 { Debug::DEBUG, "debug", N_("Developers' general debug messages")},
44 { Debug::ANY, "any", N_("All debugging messages")}
48 int const numErrorTags = sizeof(errorTags)/sizeof(error_item);
53 lyx_debug_trait::type lyx_debug_trait::value(string const & val)
58 string::size_type st = v.find(',');
59 string tmp(ascii_lowercase(v.substr(0, st)));
64 l |= static_cast<type>(convert<int>(tmp));
66 // Search for an explicit name
67 for (int i = 0 ; i < numErrorTags ; ++i)
68 if (tmp == errorTags[i].name) {
69 l |= errorTags[i].level;
72 if (st == string::npos) break;
79 void lyx_debug_trait::showLevel(ostream & os, lyx_debug_trait::type level)
81 // Show what features are traced
82 for (int i = 0; i < numErrorTags ; ++i) {
83 if (errorTags[i].level != Debug::ANY
84 && errorTags[i].level != Debug::NONE
85 && errorTags[i].level & level) {
86 // avoid _(...) re-entrance problem
87 string const s = _(errorTags[i].desc);
88 os << bformat(_("Debugging `%1$s' (%2$s)"),
97 void lyx_debug_trait::showTags(ostream & os)
99 for (int i = 0; i < numErrorTags ; ++i)
100 os << setw(7) << static_cast<unsigned int>(errorTags[i].level)
101 << setw(10) << errorTags[i].name
102 << " " << _(errorTags[i].desc) << '\n';