debug::Log can now be used instead of qDebug()

Usage:
```
QString string("world");
debug::Log("hello: {}", string);
```
This commit is contained in:
Rasmus Karlsson
2017-09-24 19:23:07 +02:00
parent af35c1f335
commit 81e06f3a53
3 changed files with 50 additions and 8 deletions
+37
View File
@@ -0,0 +1,37 @@
#pragma once
#include "fmt/format.h"
#include <QDebug>
#include <QTime>
namespace chatterino {
namespace debug {
namespace detail {
static void _log(const std::string &message)
{
qDebug().noquote() << QTime::currentTime().toString("hh:mm:ss.zzz") << message.c_str();
}
} // namespace detail
template <typename... Args>
inline void Log(const std::string &formatString, Args &&... args)
{
detail::_log(fmt::format(formatString, std::forward<Args>(args)...));
}
} // namespace debug
} // namespace chatterino
namespace fmt {
// format_arg for QString
inline void format_arg(BasicFormatter<char> &f, const char *&, const QString &v)
{
f.writer().write("\"{}\"", v.toStdString());
}
} // namespace fmt