src/support/debug.h/cpp:

- rename the private member dt to dt_,
- rename second_ and second_used_ to second_stream and second_enabled_ to have the same terminology as the stream_ and enabled_ member,
- remove FIXME because now we have a Qt pane showing the messages,
- adjust some comments.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36149 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2010-11-06 00:22:47 +00:00
parent 69dd56d6c4
commit 4397cef1f8
2 changed files with 42 additions and 48 deletions

View File

@ -143,10 +143,10 @@ Debug::Type Debug::value(string const & val)
void Debug::showLevel(ostream & os, Debug::Type level)
{
// Show what features are traced
for (int i = 0; i != numErrorTags; ++i) {
for (int i = 0; i < numErrorTags; ++i) {
if (errorTags[i].level != Debug::ANY
&& errorTags[i].level != Debug::NONE
&& errorTags[i].level & level) {
&& errorTags[i].level != Debug::NONE
&& errorTags[i].level & level) {
// avoid to_utf8(_(...)) re-entrance problem
docstring const s = _(errorTags[i].desc);
os << to_utf8(bformat(_("Debugging `%1$s' (%2$s)"),
@ -182,7 +182,7 @@ void LyXErr::enable()
bool LyXErr::debugging(Debug::Type t) const
{
return (dt & t);
return (dt_ & t);
}
@ -190,8 +190,8 @@ void LyXErr::endl()
{
if (enabled_) {
stream() << std::endl;
if (second_used_)
second() << std::endl;
if (second_enabled_)
secondStream() << std::endl;
}
}
@ -202,8 +202,8 @@ LyXErr & toStream(LyXErr & l, T t)
{
if (l.enabled()){
l.stream() << t;
if (l.second_used()) {
l.second() << t;
if (l.secondEnabled()) {
l.secondStream() << t;
ProgressInterface::instance()->lyxerrFlush();
}
}

View File

@ -2,10 +2,6 @@
/**
* \file debug.h
*
* FIXME: It would be nice if, in lyx::use_gui mode, instead of
* outputting to the console, we would pipe all messages onto a file
* and visualise the contents dynamically in a Qt window if needed.
*
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
@ -107,18 +103,13 @@ namespace Debug {
ANY = 0xffffffff
};
// Return number of levels
/// Return number of levels
int levelCount();
/** A function to convert symbolic string names on debug levels
to their numerical value.
*/
/// A function to convert debug level string names numerical values
Type value(std::string const & val);
/** A function to convert index of level to their numerical value.
*/
/// A function to convert index of level to their numerical value
Type value(int val);
/// Return description of level
@ -127,13 +118,10 @@ namespace Debug {
/// Return name of level
std::string const name(Type val);
/** Display the tags and descriptions of the current debug level
of ds
*/
/// Display the tags and descriptions of the current debug level
void showLevel(std::ostream & os, Type level);
/** show all the possible tags that can be used for debugging */
/// Show all the possible tags that can be used for debugging
void showTags(std::ostream & os);
} // namespace Debug
@ -148,45 +136,51 @@ inline void operator|=(Debug::Type & d1, Debug::Type d2)
class LyXErr
{
public:
LyXErr(): enabled_(true), second_used_(false) {}
LyXErr(): enabled_(true), second_enabled_(false) {}
/// Disable the stream completely
void disable();
/// Enable the stream after a possible call of disable()
void enable();
///
bool enabled() const { return enabled_; }
/// Returns true if t is part of the current debug level.
bool debugging(Debug::Type t = Debug::ANY) const;
/// Ends output
void endl();
/// Sets stream
void setStream(std::ostream & os) { stream_ = &os; }
/// Sets stream
/// Returns stream
std::ostream & stream() { return *stream_; }
/// Sets the debug level to t.
void setLevel(Debug::Type t) { dt = t; }
/// Returns the current debug level.
Debug::Type level() const { return dt; }
/// Returns stream
operator std::ostream &() { return *stream_; }
/// Returns second_used_
bool second_used() { return second_used_; }
// Returns second stream
std::ostream & second() { return *second_; };
/// Sets the second stream
void setSecond(std::ostream * os) { second_used_ = (second_ = os); }
/// Sets stream
void setStream(std::ostream & os) { stream_ = &os; }
/// Is the stream enabled ?
bool enabled() const { return enabled_; }
/// Returns second stream
std::ostream & secondStream() { return *second_stream_; };
/// Sets second stream
void setSecondStream(std::ostream * os)
{ second_enabled_ = (second_stream_ = os); }
/// Is the second stream is enabled?
bool secondEnabled() { return second_enabled_; }
/// Sets the debug level
void setLevel(Debug::Type t) { dt_ = t; }
/// Returns the current debug level
Debug::Type level() const { return dt_; }
/// Returns true if t is part of the current debug level
bool debugging(Debug::Type t = Debug::ANY) const;
private:
/// The current debug level
Debug::Type dt;
/// Is the stream enabled?
bool enabled_;
Debug::Type dt_;
/// The real stream
std::ostream * stream_;
/// Is the stream enabled?
bool enabled_;
/// Next stream for output duplication
std::ostream * second_;
std::ostream * second_stream_;
/// Is the second stream enabled?
bool second_used_;
bool second_enabled_;
};
namespace support { class FileName; }