mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Make debug messages more readable
Shorten the file names output by LYXERR so that they start right after /src/.
This commit is contained in:
parent
dd790192d3
commit
92e3cc456f
@ -14,10 +14,11 @@
|
|||||||
|
|
||||||
#include "support/convert.h"
|
#include "support/convert.h"
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
|
#include "support/FileName.h"
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/FileName.h"
|
|
||||||
#include "support/ProgressInterface.h"
|
#include "support/ProgressInterface.h"
|
||||||
|
#include "support/regex.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@ -197,13 +198,29 @@ void LyXErr::endl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char const * LyXErr::stripName(char const * n)
|
||||||
|
{
|
||||||
|
string const name = n;
|
||||||
|
// find the last occurence of /src/ in name
|
||||||
|
static regex re("[\\/]src[\\/]");
|
||||||
|
string::const_iterator const begin = name.begin();
|
||||||
|
string::const_iterator it = begin;
|
||||||
|
string::const_iterator const end = name.end();
|
||||||
|
smatch results;
|
||||||
|
while (regex_search(it, end, results, re)) {
|
||||||
|
it = results[0].second;
|
||||||
|
}
|
||||||
|
return n + std::distance(begin, it);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// It seems not possible to instantiate operator template out of class body
|
// It seems not possible to instantiate operator template out of class body
|
||||||
template<class T>
|
template<class T>
|
||||||
LyXErr & toStream(LyXErr & l, T t)
|
LyXErr & toStream(LyXErr & l, T t)
|
||||||
{
|
{
|
||||||
if (l.enabled()){
|
if (l.enabled()){
|
||||||
l.stream() << t;
|
l.stream() << t;
|
||||||
if (l.secondEnabled()) {
|
if (l.secondEnabled()) {
|
||||||
l.secondStream() << t;
|
l.secondStream() << t;
|
||||||
ProgressInterface::instance()->lyxerrFlush();
|
ProgressInterface::instance()->lyxerrFlush();
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,9 @@ public:
|
|||||||
/// Returns true if t is part of the current debug level
|
/// Returns true if t is part of the current debug level
|
||||||
bool debugging(Debug::Type t = Debug::ANY) const;
|
bool debugging(Debug::Type t = Debug::ANY) const;
|
||||||
|
|
||||||
|
///
|
||||||
|
static char const * stripName(char const *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// The current debug level
|
/// The current debug level
|
||||||
Debug::Type dt_;
|
Debug::Type dt_;
|
||||||
@ -208,7 +211,7 @@ extern LyXErr lyxerr;
|
|||||||
# include <boost/current_function.hpp>
|
# include <boost/current_function.hpp>
|
||||||
# define CURRENT_POSITION BOOST_CURRENT_FUNCTION ": "
|
# define CURRENT_POSITION BOOST_CURRENT_FUNCTION ": "
|
||||||
#else
|
#else
|
||||||
# define CURRENT_POSITION __FILE__ << "(" << __LINE__ << "): "
|
# define CURRENT_POSITION lyx::LyXErr::stripName(__FILE__) << " (" << __LINE__ << "): "
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LYXERR(type, msg) \
|
#define LYXERR(type, msg) \
|
||||||
|
Loading…
Reference in New Issue
Block a user