Logging: Formatting
This commit is contained in:
parent
642a455a9c
commit
7697bbfa4e
|
@ -94,7 +94,7 @@ class DebugBase : public QDebug {
|
|||
DebugBase() : QDebug(sNullDevice) {}
|
||||
explicit DebugBase(QtMsgType t) : QDebug(t) {}
|
||||
T &space() { return static_cast<T&>(QDebug::space()); }
|
||||
T& noSpace() { return static_cast<T&>(QDebug::nospace()); }
|
||||
T &nospace() { return static_cast<T&>(QDebug::nospace()); }
|
||||
};
|
||||
|
||||
// Debug message will be stored in a buffer.
|
||||
|
@ -173,6 +173,7 @@ void Init() {
|
|||
if (!sOriginalMessageHandler) {
|
||||
sOriginalMessageHandler = qInstallMessageHandler(MessageHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SetLevels(const QString &levels) {
|
||||
|
@ -229,6 +230,7 @@ static QString ParsePrettyFunction(const char *pretty_function) {
|
|||
}
|
||||
|
||||
return class_name;
|
||||
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -269,11 +271,10 @@ static T CreateLogger(Level level, const QString &class_name, int line, const ch
|
|||
}
|
||||
|
||||
T ret(type);
|
||||
ret.nospace() << QDateTime::currentDateTime().toString("hh:mm:ss.zzz").toLatin1().constData()
|
||||
<< level_name
|
||||
<< function_line.leftJustified(32).toLatin1().constData();
|
||||
ret.nospace() << QDateTime::currentDateTime().toString("hh:mm:ss.zzz").toLatin1().constData() << level_name << function_line.leftJustified(32).toLatin1().constData();
|
||||
|
||||
return ret.space();
|
||||
|
||||
}
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
|
@ -303,6 +304,7 @@ QString LinuxDemangle(const QString &symbol) {
|
|||
}
|
||||
QString mangled_function = match.captured(1);
|
||||
return CXXDemangle(mangled_function);
|
||||
|
||||
}
|
||||
#endif // Q_OS_LINUX
|
||||
|
||||
|
@ -323,6 +325,7 @@ QString DarwinDemangle(const QString &symbol) {
|
|||
|
||||
QString DemangleSymbol(const QString &symbol);
|
||||
QString DemangleSymbol(const QString &symbol) {
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
return DarwinDemangle(symbol);
|
||||
#elif defined(Q_OS_LINUX)
|
||||
|
@ -330,9 +333,11 @@ QString DemangleSymbol(const QString &symbol) {
|
|||
#else
|
||||
return symbol;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void DumpStackTrace() {
|
||||
|
||||
#ifdef HAVE_BACKTRACE
|
||||
void *callstack[128];
|
||||
int callstack_size = backtrace(reinterpret_cast<void**>(&callstack), sizeof(callstack));
|
||||
|
@ -345,11 +350,11 @@ void DumpStackTrace() {
|
|||
#else
|
||||
qLog(Debug) << "FIXME: Implement printing stack traces on this platform";
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// These are the functions that create loggers for the rest of Clementine.
|
||||
// It's okay that the LoggedDebug instance is copied to a QDebug in these. It
|
||||
// doesn't override any behavior that should be needed after return.
|
||||
// These are the functions that create loggers for the rest of Strawberry.
|
||||
// It's okay that the LoggedDebug instance is copied to a QDebug in these. It doesn't override any behavior that should be needed after return.
|
||||
#define qCreateLogger(line, pretty_function, category, level) logging::CreateLogger<LoggedDebug>(logging::Level_##level, logging::ParsePrettyFunction(pretty_function), line, category)
|
||||
|
||||
QDebug CreateLoggerInfo(int line, const char *pretty_function, const char *category) { return qCreateLogger(line, pretty_function, category, Info); }
|
||||
|
@ -383,4 +388,3 @@ QDebug operator<<(QDebug dbg, std::chrono::seconds secs) {
|
|||
dbg.nospace() << print_duration(secs, "s");
|
||||
return dbg.space();
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ QDebug CreateLoggerError(int line, const char *pretty_function, const char* cate
|
|||
QDebug CreateLoggerDebug(int line, const char *pretty_function, const char *category);
|
||||
#endif // QT_NO_DEBUG_OUTPUT
|
||||
|
||||
|
||||
void GLog(const char *domain, int level, const char *message, void *user_data);
|
||||
|
||||
extern const char *kDefaultLogLevels;
|
||||
|
|
Loading…
Reference in New Issue