mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +00:00
Remove client/debug.* since they are not used anymore.
Moreover they cause problems wrt make dist. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25021 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fe1d23c7af
commit
7d4c55677c
@ -1,159 +0,0 @@
|
||||
/**
|
||||
* \file debug.cpp
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Lars Gullik Bjønnes
|
||||
* \author Jean-Marc Lasgouttes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/gettext.h"
|
||||
|
||||
#include "support/convert.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/FileName.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
using namespace lyx::support;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace {
|
||||
|
||||
struct ErrorItem {
|
||||
Debug::Type level;
|
||||
char const * name;
|
||||
char const * desc;
|
||||
};
|
||||
|
||||
|
||||
ErrorItem errorTags[] = {
|
||||
{ Debug::NONE, "none", N_("No debugging message")},
|
||||
{ Debug::INFO, "info", N_("General information")},
|
||||
{ Debug::DEBUG, "debug", N_("Developers' general debug messages")},
|
||||
{ Debug::ANY, "any", N_("All debugging messages")}
|
||||
};
|
||||
|
||||
|
||||
int const numErrorTags = sizeof(errorTags)/sizeof(errorTags[0]);
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
Debug::Type Debug::value(string const & val)
|
||||
{
|
||||
Type l = Debug::NONE;
|
||||
string v(val);
|
||||
while (!v.empty()) {
|
||||
string::size_type const st = v.find(',');
|
||||
string const tmp(ascii_lowercase(v.substr(0, st)));
|
||||
if (tmp.empty())
|
||||
break;
|
||||
// Is it a number?
|
||||
if (isStrInt(tmp))
|
||||
l |= static_cast<Type>(convert<int>(tmp));
|
||||
else
|
||||
// Search for an explicit name
|
||||
for (int i = 0 ; i < numErrorTags ; ++i)
|
||||
if (tmp == errorTags[i].name) {
|
||||
l |= errorTags[i].level;
|
||||
break;
|
||||
}
|
||||
if (st == string::npos) break;
|
||||
v.erase(0, st + 1);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
void Debug::showLevel(ostream & os, Debug::Type level)
|
||||
{
|
||||
// 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) {
|
||||
// avoid to_utf8(_(...)) re-entrance problem
|
||||
docstring const s = _(errorTags[i].desc);
|
||||
os << to_utf8(bformat(_("Debugging `%1$s' (%2$s)"),
|
||||
from_utf8(errorTags[i].name), s))
|
||||
<< '\n';
|
||||
}
|
||||
}
|
||||
os.flush();
|
||||
}
|
||||
|
||||
|
||||
void Debug::showTags(ostream & os)
|
||||
{
|
||||
for (int i = 0; i < numErrorTags ; ++i)
|
||||
os << setw(10) << static_cast<unsigned int>(errorTags[i].level)
|
||||
<< setw(13) << errorTags[i].name
|
||||
<< " " << to_utf8(_(errorTags[i].desc)) << '\n';
|
||||
os.flush();
|
||||
}
|
||||
|
||||
|
||||
void LyXErr::disable()
|
||||
{
|
||||
enabled_ = false;
|
||||
}
|
||||
|
||||
|
||||
void LyXErr::enable()
|
||||
{
|
||||
enabled_ = true;
|
||||
}
|
||||
|
||||
|
||||
bool LyXErr::debugging(Debug::Type t) const
|
||||
{
|
||||
return (dt & t);
|
||||
}
|
||||
|
||||
|
||||
void LyXErr::endl()
|
||||
{
|
||||
stream() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
LyXErr & operator<<(LyXErr & l, void const * t)
|
||||
{ l.stream() << t; return l; }
|
||||
LyXErr & operator<<(LyXErr & l, char const * t)
|
||||
{ l.stream() << t; return l; }
|
||||
LyXErr & operator<<(LyXErr & l, char t)
|
||||
{ l.stream() << t; return l; }
|
||||
LyXErr & operator<<(LyXErr & l, int t)
|
||||
{ l.stream() << t; return l; }
|
||||
LyXErr & operator<<(LyXErr & l, unsigned int t)
|
||||
{ l.stream() << t; return l; }
|
||||
LyXErr & operator<<(LyXErr & l, long t)
|
||||
{ l.stream() << t; return l; }
|
||||
LyXErr & operator<<(LyXErr & l, unsigned long t)
|
||||
{ l.stream() << t; return l; }
|
||||
LyXErr & operator<<(LyXErr & l, double t)
|
||||
{ l.stream() << t; return l; }
|
||||
LyXErr & operator<<(LyXErr & l, string const & t)
|
||||
{ l.stream() << t; return l; }
|
||||
LyXErr & operator<<(LyXErr & l, docstring const & t)
|
||||
{ l.stream() << to_utf8(t); return l; }
|
||||
LyXErr & operator<<(LyXErr & l, FileName const & t)
|
||||
{ l.stream() << t; return l; }
|
||||
LyXErr & operator<<(LyXErr & l, ostream &(*t)(ostream &))
|
||||
{ l.stream() << t; return l; }
|
||||
LyXErr & operator<<(LyXErr & l, ios_base &(*t)(ios_base &))
|
||||
{ l.stream() << t; return l; }
|
||||
|
||||
LyXErr lyxerr;
|
||||
|
||||
|
||||
} // namespace lyx
|
@ -1,116 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file debug.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Lars Gullik Bjønnes
|
||||
* \author Jean-Marc Lasgouttes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef LYXDEBUG_H
|
||||
#define LYXDEBUG_H
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
/** Ideally this should have been a namespace, but since we try to be
|
||||
* compilable on older C++ compilators too, we use a struct instead.
|
||||
* This is all the different debug levels that we have.
|
||||
*/
|
||||
class Debug {
|
||||
public:
|
||||
///
|
||||
enum Type {
|
||||
///
|
||||
NONE = 0,
|
||||
///
|
||||
INFO = (1 << 0),
|
||||
///
|
||||
DEBUG = (1 << 31),
|
||||
///
|
||||
ANY = 0xffffffff
|
||||
};
|
||||
|
||||
/** A function to convert symbolic string names on debug levels
|
||||
to their numerical value.
|
||||
*/
|
||||
static Type value(std::string const & val);
|
||||
|
||||
/** Display the tags and descriptions of the current debug level
|
||||
of ds
|
||||
*/
|
||||
static void showLevel(std::ostream & o, Type level);
|
||||
|
||||
/** show all the possible tags that can be used for debugging */
|
||||
static void showTags(std::ostream & o);
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline void operator|=(Debug::Type & d1, Debug::Type d2)
|
||||
{
|
||||
d1 = static_cast<Debug::Type>(d1 | d2);
|
||||
}
|
||||
|
||||
|
||||
class LyXErr
|
||||
{
|
||||
public:
|
||||
/// Disable the stream completely
|
||||
void disable();
|
||||
/// Enable the stream after a possible call of disable()
|
||||
void enable();
|
||||
/// 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
|
||||
std::ostream & stream() { return *stream_; }
|
||||
/// Sets the debug level to t.
|
||||
void level(Debug::Type t) { dt = t; }
|
||||
/// Returns the current debug level.
|
||||
Debug::Type level() const { return dt; }
|
||||
/// Returns stream
|
||||
operator std::ostream &() { return *stream_; }
|
||||
private:
|
||||
/// The current debug level
|
||||
Debug::Type dt;
|
||||
/// Is the stream enabled?
|
||||
bool enabled_;
|
||||
/// The real stream
|
||||
std::ostream * stream_;
|
||||
};
|
||||
|
||||
namespace support { class FileName; }
|
||||
|
||||
LyXErr & operator<<(LyXErr &, void const *);
|
||||
LyXErr & operator<<(LyXErr &, char const *);
|
||||
LyXErr & operator<<(LyXErr &, char);
|
||||
LyXErr & operator<<(LyXErr &, int);
|
||||
LyXErr & operator<<(LyXErr &, unsigned int);
|
||||
LyXErr & operator<<(LyXErr &, long);
|
||||
LyXErr & operator<<(LyXErr &, unsigned long);
|
||||
LyXErr & operator<<(LyXErr &, double);
|
||||
LyXErr & operator<<(LyXErr &, std::string const &);
|
||||
LyXErr & operator<<(LyXErr &, docstring const &);
|
||||
LyXErr & operator<<(LyXErr &, std::ostream &(*)(std::ostream &));
|
||||
LyXErr & operator<<(LyXErr &, std::ios_base &(*)(std::ios_base &));
|
||||
LyXErr & operator<<(LyXErr & l, support::FileName const & t);
|
||||
|
||||
extern LyXErr lyxerr;
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#define LYXERR(type, msg) \
|
||||
do { if (!lyx::lyxerr.debugging(type)) {} \
|
||||
else lyx::lyxerr << msg << std::endl; } while (0)
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user