Remove FMT dependency (#1472)

All occurrences of log() have been replaced with qDebug()

bonus meme: remove a bunch of std::string usages in the pubsub client

Fixes #1467
This commit is contained in:
pajlada 2020-01-03 20:51:37 +01:00 committed by GitHub
parent f02988b657
commit 3c8992cac1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 230 additions and 4920 deletions

View file

@ -1,7 +1,4 @@
# Exposed build flags:
# from lib/fmt.pri
# - FMT_PREFIX ($$PWD by default)
# - FMT_SYSTEM (1 = true) (Linux only, uses pkg-config)
# from lib/websocketpp.pri
# - WEBSOCKETPP_PREFIX ($$PWD by default)
# - WEBSOCKETPP_SYSTEM (1 = true) (unix only)
@ -76,7 +73,6 @@ CONFIG(debug, debug|release) {
# Submodules
include(lib/warnings.pri)
include(lib/fmt.pri)
include(lib/humanize.pri)
include(lib/libcommuni.pri)
include(lib/websocketpp.pri)
@ -344,7 +340,6 @@ HEADERS += \
src/controllers/taggedusers/TaggedUsersModel.hpp \
src/debug/AssertInGuiThread.hpp \
src/debug/Benchmark.hpp \
src/debug/Log.hpp \
src/ForwardDecl.hpp \
src/messages/Emote.hpp \
src/messages/Image.hpp \

View file

@ -1,18 +0,0 @@
# fmt
# Chatterino2 is tested with FMT 4.0
# Exposed build flags:
# - FMT_PREFIX ($$PWD by default)
# - FMT_SYSTEM (1 = true) (Linux only, uses pkg-config)
!defined(FMT_PREFIX) {
FMT_PREFIX = $$PWD
}
linux:equals(FMT_SYSTEM, "1") {
message("Building with system FMT")
PKGCONFIG += fmt
} else {
SOURCES += $$FMT_PREFIX/fmt/fmt/format.cpp
INCLUDEPATH += $$PWD/fmt/
}

View file

@ -1,535 +0,0 @@
/*
Formatting library for C++
Copyright (c) 2012 - 2016, Victor Zverovich
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "format.h"
#include <string.h>
#include <cctype>
#include <cerrno>
#include <climits>
#include <cmath>
#include <cstdarg>
#include <cstddef> // for std::ptrdiff_t
#if defined(_WIN32) && defined(__MINGW32__)
# include <cstring>
#endif
#if FMT_USE_WINDOWS_H
# if !defined(FMT_HEADER_ONLY) && !defined(WIN32_LEAN_AND_MEAN)
# define WIN32_LEAN_AND_MEAN
# endif
# if defined(NOMINMAX) || defined(FMT_WIN_MINMAX)
# include <windows.h>
# else
# define NOMINMAX
# include <windows.h>
# undef NOMINMAX
# endif
#endif
#if FMT_EXCEPTIONS
# define FMT_TRY try
# define FMT_CATCH(x) catch (x)
#else
# define FMT_TRY if (true)
# define FMT_CATCH(x) if (false)
#endif
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable: 4127) // conditional expression is constant
# pragma warning(disable: 4702) // unreachable code
// Disable deprecation warning for strerror. The latter is not called but
// MSVC fails to detect it.
# pragma warning(disable: 4996)
#endif
// Dummy implementations of strerror_r and strerror_s called if corresponding
// system functions are not available.
static inline fmt::internal::Null<> strerror_r(int, char *, ...) {
return fmt::internal::Null<>();
}
static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) {
return fmt::internal::Null<>();
}
namespace fmt {
FMT_FUNC internal::RuntimeError::~RuntimeError() FMT_DTOR_NOEXCEPT {}
FMT_FUNC FormatError::~FormatError() FMT_DTOR_NOEXCEPT {}
FMT_FUNC SystemError::~SystemError() FMT_DTOR_NOEXCEPT {}
namespace {
#ifndef _MSC_VER
# define FMT_SNPRINTF snprintf
#else // _MSC_VER
inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) {
va_list args;
va_start(args, format);
int result = vsnprintf_s(buffer, size, _TRUNCATE, format, args);
va_end(args);
return result;
}
# define FMT_SNPRINTF fmt_snprintf
#endif // _MSC_VER
#if defined(_WIN32) && defined(__MINGW32__) && !defined(__NO_ISOCEXT)
# define FMT_SWPRINTF snwprintf
#else
# define FMT_SWPRINTF swprintf
#endif // defined(_WIN32) && defined(__MINGW32__) && !defined(__NO_ISOCEXT)
const char RESET_COLOR[] = "\x1b[0m";
typedef void (*FormatFunc)(Writer &, int, StringRef);
// Portable thread-safe version of strerror.
// Sets buffer to point to a string describing the error code.
// This can be either a pointer to a string stored in buffer,
// or a pointer to some static immutable string.
// Returns one of the following values:
// 0 - success
// ERANGE - buffer is not large enough to store the error message
// other - failure
// Buffer should be at least of size 1.
int safe_strerror(
int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT {
FMT_ASSERT(buffer != 0 && buffer_size != 0, "invalid buffer");
class StrError {
private:
int error_code_;
char *&buffer_;
std::size_t buffer_size_;
// A noop assignment operator to avoid bogus warnings.
void operator=(const StrError &) {}
// Handle the result of XSI-compliant version of strerror_r.
int handle(int result) {
// glibc versions before 2.13 return result in errno.
return result == -1 ? errno : result;
}
// Handle the result of GNU-specific version of strerror_r.
int handle(char *message) {
// If the buffer is full then the message is probably truncated.
if (message == buffer_ && strlen(buffer_) == buffer_size_ - 1)
return ERANGE;
buffer_ = message;
return 0;
}
// Handle the case when strerror_r is not available.
int handle(internal::Null<>) {
return fallback(strerror_s(buffer_, buffer_size_, error_code_));
}
// Fallback to strerror_s when strerror_r is not available.
int fallback(int result) {
// If the buffer is full then the message is probably truncated.
return result == 0 && strlen(buffer_) == buffer_size_ - 1 ?
ERANGE : result;
}
// Fallback to strerror if strerror_r and strerror_s are not available.
int fallback(internal::Null<>) {
errno = 0;
buffer_ = strerror(error_code_);
return errno;
}
public:
StrError(int err_code, char *&buf, std::size_t buf_size)
: error_code_(err_code), buffer_(buf), buffer_size_(buf_size) {}
int run() {
// Suppress a warning about unused strerror_r.
strerror_r(0, FMT_NULL, "");
return handle(strerror_r(error_code_, buffer_, buffer_size_));
}
};
return StrError(error_code, buffer, buffer_size).run();
}
void format_error_code(Writer &out, int error_code,
StringRef message) FMT_NOEXCEPT {
// Report error code making sure that the output fits into
// INLINE_BUFFER_SIZE to avoid dynamic memory allocation and potential
// bad_alloc.
out.clear();
static const char SEP[] = ": ";
static const char ERROR_STR[] = "error ";
// Subtract 2 to account for terminating null characters in SEP and ERROR_STR.
std::size_t error_code_size = sizeof(SEP) + sizeof(ERROR_STR) - 2;
typedef internal::IntTraits<int>::MainType MainType;
MainType abs_value = static_cast<MainType>(error_code);
if (internal::is_negative(error_code)) {
abs_value = 0 - abs_value;
++error_code_size;
}
error_code_size += internal::count_digits(abs_value);
if (message.size() <= internal::INLINE_BUFFER_SIZE - error_code_size)
out << message << SEP;
out << ERROR_STR << error_code;
assert(out.size() <= internal::INLINE_BUFFER_SIZE);
}
void report_error(FormatFunc func, int error_code,
StringRef message) FMT_NOEXCEPT {
MemoryWriter full_message;
func(full_message, error_code, message);
// Use Writer::data instead of Writer::c_str to avoid potential memory
// allocation.
std::fwrite(full_message.data(), full_message.size(), 1, stderr);
std::fputc('\n', stderr);
}
} // namespace
FMT_FUNC void SystemError::init(
int err_code, CStringRef format_str, ArgList args) {
error_code_ = err_code;
MemoryWriter w;
format_system_error(w, err_code, format(format_str, args));
std::runtime_error &base = *this;
base = std::runtime_error(w.str());
}
template <typename T>
int internal::CharTraits<char>::format_float(
char *buffer, std::size_t size, const char *format,
unsigned width, int precision, T value) {
if (width == 0) {
return precision < 0 ?
FMT_SNPRINTF(buffer, size, format, value) :
FMT_SNPRINTF(buffer, size, format, precision, value);
}
return precision < 0 ?
FMT_SNPRINTF(buffer, size, format, width, value) :
FMT_SNPRINTF(buffer, size, format, width, precision, value);
}
template <typename T>
int internal::CharTraits<wchar_t>::format_float(
wchar_t *buffer, std::size_t size, const wchar_t *format,
unsigned width, int precision, T value) {
if (width == 0) {
return precision < 0 ?
FMT_SWPRINTF(buffer, size, format, value) :
FMT_SWPRINTF(buffer, size, format, precision, value);
}
return precision < 0 ?
FMT_SWPRINTF(buffer, size, format, width, value) :
FMT_SWPRINTF(buffer, size, format, width, precision, value);
}
template <typename T>
const char internal::BasicData<T>::DIGITS[] =
"0001020304050607080910111213141516171819"
"2021222324252627282930313233343536373839"
"4041424344454647484950515253545556575859"
"6061626364656667686970717273747576777879"
"8081828384858687888990919293949596979899";
#define FMT_POWERS_OF_10(factor) \
factor * 10, \
factor * 100, \
factor * 1000, \
factor * 10000, \
factor * 100000, \
factor * 1000000, \
factor * 10000000, \
factor * 100000000, \
factor * 1000000000
template <typename T>
const uint32_t internal::BasicData<T>::POWERS_OF_10_32[] = {
0, FMT_POWERS_OF_10(1)
};
template <typename T>
const uint64_t internal::BasicData<T>::POWERS_OF_10_64[] = {
0,
FMT_POWERS_OF_10(1),
FMT_POWERS_OF_10(ULongLong(1000000000)),
// Multiply several constants instead of using a single long long constant
// to avoid warnings about C++98 not supporting long long.
ULongLong(1000000000) * ULongLong(1000000000) * 10
};
FMT_FUNC void internal::report_unknown_type(char code, const char *type) {
(void)type;
if (std::isprint(static_cast<unsigned char>(code))) {
FMT_THROW(FormatError(
format("unknown format code '{}' for {}", code, type)));
}
FMT_THROW(FormatError(
format("unknown format code '\\x{:02x}' for {}",
static_cast<unsigned>(code), type)));
}
#if FMT_USE_WINDOWS_H
FMT_FUNC internal::UTF8ToUTF16::UTF8ToUTF16(StringRef s) {
static const char ERROR_MSG[] = "cannot convert string from UTF-8 to UTF-16";
if (s.size() > INT_MAX)
FMT_THROW(WindowsError(ERROR_INVALID_PARAMETER, ERROR_MSG));
int s_size = static_cast<int>(s.size());
int length = MultiByteToWideChar(
CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, FMT_NULL, 0);
if (length == 0)
FMT_THROW(WindowsError(GetLastError(), ERROR_MSG));
buffer_.resize(length + 1);
length = MultiByteToWideChar(
CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size, &buffer_[0], length);
if (length == 0)
FMT_THROW(WindowsError(GetLastError(), ERROR_MSG));
buffer_[length] = 0;
}
FMT_FUNC internal::UTF16ToUTF8::UTF16ToUTF8(WStringRef s) {
if (int error_code = convert(s)) {
FMT_THROW(WindowsError(error_code,
"cannot convert string from UTF-16 to UTF-8"));
}
}
FMT_FUNC int internal::UTF16ToUTF8::convert(WStringRef s) {
if (s.size() > INT_MAX)
return ERROR_INVALID_PARAMETER;
int s_size = static_cast<int>(s.size());
int length = WideCharToMultiByte(
CP_UTF8, 0, s.data(), s_size, FMT_NULL, 0, FMT_NULL, FMT_NULL);
if (length == 0)
return GetLastError();
buffer_.resize(length + 1);
length = WideCharToMultiByte(
CP_UTF8, 0, s.data(), s_size, &buffer_[0], length, FMT_NULL, FMT_NULL);
if (length == 0)
return GetLastError();
buffer_[length] = 0;
return 0;
}
FMT_FUNC void WindowsError::init(
int err_code, CStringRef format_str, ArgList args) {
error_code_ = err_code;
MemoryWriter w;
internal::format_windows_error(w, err_code, format(format_str, args));
std::runtime_error &base = *this;
base = std::runtime_error(w.str());
}
FMT_FUNC void internal::format_windows_error(
Writer &out, int error_code, StringRef message) FMT_NOEXCEPT {
FMT_TRY {
MemoryBuffer<wchar_t, INLINE_BUFFER_SIZE> buffer;
buffer.resize(INLINE_BUFFER_SIZE);
for (;;) {
wchar_t *system_message = &buffer[0];
int result = FormatMessageW(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
FMT_NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
system_message, static_cast<uint32_t>(buffer.size()), FMT_NULL);
if (result != 0) {
UTF16ToUTF8 utf8_message;
if (utf8_message.convert(system_message) == ERROR_SUCCESS) {
out << message << ": " << utf8_message;
return;
}
break;
}
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
break; // Can't get error message, report error code instead.
buffer.resize(buffer.size() * 2);
}
} FMT_CATCH(...) {}
fmt::format_error_code(out, error_code, message); // 'fmt::' is for bcc32.
}
#endif // FMT_USE_WINDOWS_H
FMT_FUNC void format_system_error(
Writer &out, int error_code, StringRef message) FMT_NOEXCEPT {
FMT_TRY {
internal::MemoryBuffer<char, internal::INLINE_BUFFER_SIZE> buffer;
buffer.resize(internal::INLINE_BUFFER_SIZE);
for (;;) {
char *system_message = &buffer[0];
int result = safe_strerror(error_code, system_message, buffer.size());
if (result == 0) {
out << message << ": " << system_message;
return;
}
if (result != ERANGE)
break; // Can't get error message, report error code instead.
buffer.resize(buffer.size() * 2);
}
} FMT_CATCH(...) {}
fmt::format_error_code(out, error_code, message); // 'fmt::' is for bcc32.
}
template <typename Char>
void internal::ArgMap<Char>::init(const ArgList &args) {
if (!map_.empty())
return;
typedef internal::NamedArg<Char> NamedArg;
const NamedArg *named_arg = FMT_NULL;
bool use_values =
args.type(ArgList::MAX_PACKED_ARGS - 1) == internal::Arg::NONE;
if (use_values) {
for (unsigned i = 0;/*nothing*/; ++i) {
internal::Arg::Type arg_type = args.type(i);
switch (arg_type) {
case internal::Arg::NONE:
return;
case internal::Arg::NAMED_ARG:
named_arg = static_cast<const NamedArg*>(args.values_[i].pointer);
map_.push_back(Pair(named_arg->name, *named_arg));
break;
default:
/*nothing*/;
}
}
return;
}
for (unsigned i = 0; i != ArgList::MAX_PACKED_ARGS; ++i) {
internal::Arg::Type arg_type = args.type(i);
if (arg_type == internal::Arg::NAMED_ARG) {
named_arg = static_cast<const NamedArg*>(args.args_[i].pointer);
map_.push_back(Pair(named_arg->name, *named_arg));
}
}
for (unsigned i = ArgList::MAX_PACKED_ARGS;/*nothing*/; ++i) {
switch (args.args_[i].type) {
case internal::Arg::NONE:
return;
case internal::Arg::NAMED_ARG:
named_arg = static_cast<const NamedArg*>(args.args_[i].pointer);
map_.push_back(Pair(named_arg->name, *named_arg));
break;
default:
/*nothing*/;
}
}
}
template <typename Char>
void internal::FixedBuffer<Char>::grow(std::size_t) {
FMT_THROW(std::runtime_error("buffer overflow"));
}
FMT_FUNC internal::Arg internal::FormatterBase::do_get_arg(
unsigned arg_index, const char *&error) {
internal::Arg arg = args_[arg_index];
switch (arg.type) {
case internal::Arg::NONE:
error = "argument index out of range";
break;
case internal::Arg::NAMED_ARG:
arg = *static_cast<const internal::Arg*>(arg.pointer);
break;
default:
/*nothing*/;
}
return arg;
}
FMT_FUNC void report_system_error(
int error_code, fmt::StringRef message) FMT_NOEXCEPT {
// 'fmt::' is for bcc32.
report_error(format_system_error, error_code, message);
}
#if FMT_USE_WINDOWS_H
FMT_FUNC void report_windows_error(
int error_code, fmt::StringRef message) FMT_NOEXCEPT {
// 'fmt::' is for bcc32.
report_error(internal::format_windows_error, error_code, message);
}
#endif
FMT_FUNC void print(std::FILE *f, CStringRef format_str, ArgList args) {
MemoryWriter w;
w.write(format_str, args);
std::fwrite(w.data(), 1, w.size(), f);
}
FMT_FUNC void print(CStringRef format_str, ArgList args) {
print(stdout, format_str, args);
}
FMT_FUNC void print_colored(Color c, CStringRef format, ArgList args) {
char escape[] = "\x1b[30m";
escape[3] = static_cast<char>('0' + c);
std::fputs(escape, stdout);
print(format, args);
std::fputs(RESET_COLOR, stdout);
}
#ifndef FMT_HEADER_ONLY
template struct internal::BasicData<void>;
// Explicit instantiations for char.
template void internal::FixedBuffer<char>::grow(std::size_t);
template void internal::ArgMap<char>::init(const ArgList &args);
template FMT_API int internal::CharTraits<char>::format_float(
char *buffer, std::size_t size, const char *format,
unsigned width, int precision, double value);
template FMT_API int internal::CharTraits<char>::format_float(
char *buffer, std::size_t size, const char *format,
unsigned width, int precision, long double value);
// Explicit instantiations for wchar_t.
template void internal::FixedBuffer<wchar_t>::grow(std::size_t);
template void internal::ArgMap<wchar_t>::init(const ArgList &args);
template FMT_API int internal::CharTraits<wchar_t>::format_float(
wchar_t *buffer, std::size_t size, const wchar_t *format,
unsigned width, int precision, double value);
template FMT_API int internal::CharTraits<wchar_t>::format_float(
wchar_t *buffer, std::size_t size, const wchar_t *format,
unsigned width, int precision, long double value);
#endif // FMT_HEADER_ONLY
} // namespace fmt
#ifdef _MSC_VER
# pragma warning(pop)
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,23 +0,0 @@
Copyright (c) 2012 - 2016, Victor Zverovich
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -40,7 +40,6 @@
<file>icon.png</file>
<file>licenses/boost_boost.txt</file>
<file>licenses/emoji-data-source.txt</file>
<file>licenses/fmt_bsd2.txt</file>
<file>licenses/libcommuni_BSD3.txt</file>
<file>licenses/openssl.txt</file>
<file>licenses/pajlada_settings.txt</file>

View file

@ -11,7 +11,6 @@
#include "controllers/notifications/NotificationController.hpp"
#include "controllers/pings/PingController.hpp"
#include "controllers/taggedusers/TaggedUsersController.hpp"
#include "debug/Log.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/chatterino/ChatterinoBadges.hpp"
@ -158,11 +157,11 @@ void Application::initNm(Paths &paths)
void Application::initPubsub()
{
this->twitch.pubsub->signals_.whisper.sent.connect([](const auto &msg) {
log("WHISPER SENT LOL"); //
qDebug() << "WHISPER SENT LOL"; //
});
this->twitch.pubsub->signals_.whisper.received.connect([](const auto &msg) {
log("WHISPER RECEIVED LOL"); //
qDebug() << "WHISPER RECEIVED LOL"; //
});
this->twitch.pubsub->signals_.moderation.chatCleared.connect(

View file

@ -1,7 +1,6 @@
#pragma once
#ifdef __cplusplus
# include <fmt/format.h>
# include <irccommand.h>
# include <ircconnection.h>
# include <rapidjson/document.h>

View file

@ -1,7 +1,6 @@
#include "common/Channel.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "singletons/Emotes.hpp"

View file

@ -6,7 +6,6 @@
#include "controllers/accounts/AccountController.hpp"
#include "controllers/commands/CommandController.hpp"
#include "debug/Benchmark.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/Emotes.hpp"

View file

@ -1,6 +1,5 @@
#include "DownloadManager.hpp"
#include "debug/Log.hpp"
#include "singletons/Paths.hpp"
#include <QDesktopServices>
@ -41,7 +40,7 @@ void DownloadManager::setFile(QString fileURL, const QString &channelName)
void DownloadManager::onDownloadProgress(qint64 bytesRead, qint64 bytesTotal)
{
log("Download progress: {}/{}", bytesRead, bytesTotal);
qDebug() << "Download progress: " << bytesRead << "/" << bytesTotal;
}
void DownloadManager::onFinished(QNetworkReply *reply)

View file

@ -4,7 +4,6 @@
#include "common/NetworkResult.hpp"
#include "common/Outcome.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "debug/Log.hpp"
#include "singletons/Paths.hpp"
#include "util/DebugCount.hpp"
#include "util/PostToThread.hpp"
@ -124,7 +123,7 @@ void loadUncached(const std::shared_ptr<NetworkData> &data)
if (reply == nullptr)
{
log("Unhandled request type");
qDebug() << "Unhandled request type";
return;
}
@ -132,7 +131,7 @@ void loadUncached(const std::shared_ptr<NetworkData> &data)
{
QObject::connect(
data->timer_, &QTimer::timeout, worker, [reply, data]() {
log("Aborted!");
qDebug() << "Aborted!";
reply->abort();
if (data->onError_)
{

View file

@ -4,7 +4,6 @@
#include "common/Outcome.hpp"
#include "common/Version.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchCommon.hpp"
#include "singletons/Paths.hpp"
#include "util/DebugCount.hpp"

View file

@ -1,7 +1,5 @@
#include "common/NetworkResult.hpp"
#include "debug/Log.hpp"
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
#include <QJsonDocument>
@ -45,8 +43,9 @@ rapidjson::Document NetworkResult::parseRapidJson() const
if (result.Code() != rapidjson::kParseErrorNone)
{
log("JSON parse error: {} ({})",
rapidjson::GetParseError_En(result.Code()), result.Offset());
qDebug() << "JSON parse error:"
<< rapidjson::GetParseError_En(result.Code()) << "("
<< result.Offset() << ")";
return ret;
}

View file

@ -5,7 +5,6 @@
#include "controllers/accounts/AccountController.hpp"
#include "controllers/commands/Command.hpp"
#include "controllers/commands/CommandModel.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "messages/MessageElement.hpp"

View file

@ -4,7 +4,6 @@
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "controllers/notifications/NotificationModel.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchApi.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/Toasts.hpp"
@ -147,12 +146,13 @@ void NotificationController::getFakeTwitchChannelLiveStatus(
TwitchApi::findUserId(channelName, [channelName, this](QString roomID) {
if (roomID.isEmpty())
{
log("[TwitchChannel:{}] Refreshing live status (Missing ID)",
channelName);
qDebug() << "[TwitchChannel" << channelName
<< "] Refreshing live status (Missing ID)";
removeFakeChannel(channelName);
return;
}
log("[TwitchChannel:{}] Refreshing live status", channelName);
qDebug() << "[TwitchChannel" << channelName
<< "] Refreshing live status";
QString url("https://api.twitch.tv/kraken/streams/" + roomID);
NetworkRequest::twitchRequest(url)
@ -160,15 +160,15 @@ void NotificationController::getFakeTwitchChannelLiveStatus(
rapidjson::Document document = result.parseRapidJson();
if (!document.IsObject())
{
log("[TwitchChannel:refreshLiveStatus]root is not an "
"object");
qDebug() << "[TwitchChannel:refreshLiveStatus] root is not "
"an object";
return Failure;
}
if (!document.HasMember("stream"))
{
log("[TwitchChannel:refreshLiveStatus] Missing stream in "
"root");
qDebug() << "[TwitchChannel:refreshLiveStatus] Missing "
"stream in root";
return Failure;
}

View file

@ -10,7 +10,8 @@ BenchmarkGuard::BenchmarkGuard(const QString &_name)
BenchmarkGuard::~BenchmarkGuard()
{
log("{} {} ms", this->name_, float(timer_.nsecsElapsed()) / 1000000.0f);
qDebug() << this->name_ << float(timer_.nsecsElapsed()) / 1000000.0f
<< "ms";
}
qreal BenchmarkGuard::getElapsedMs()

View file

@ -1,7 +1,6 @@
#pragma once
#include "debug/Log.hpp"
#include <QDebug>
#include <QElapsedTimer>
#include <boost/noncopyable.hpp>

View file

@ -1,29 +0,0 @@
#pragma once
#include "util/Helpers.hpp"
#include <QDebug>
#include <QTime>
namespace chatterino {
template <typename... Args>
inline void log(const std::string &formatString, Args &&... args)
{
qDebug().noquote() << QTime::currentTime().toString("hh:mm:ss.zzz")
<< fS(formatString, std::forward<Args>(args)...).c_str();
}
template <typename... Args>
inline void log(const char *formatString, Args &&... args)
{
log(std::string(formatString), std::forward<Args>(args)...);
}
template <typename... Args>
inline void log(const QString &formatString, Args &&... args)
{
log(formatString.toStdString(), std::forward<Args>(args)...);
}
} // namespace chatterino

View file

@ -14,7 +14,6 @@
#include "common/NetworkRequest.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "debug/Benchmark.hpp"
#include "debug/Log.hpp"
#include "singletons/Emotes.hpp"
#include "singletons/WindowManager.hpp"
#include "util/DebugCount.hpp"
@ -108,8 +107,8 @@ namespace detail {
if (reader.imageCount() == 0)
{
log("Error while reading image {}: '{}'", url.string,
reader.errorString());
qDebug() << "Error while reading image" << url.string << ": '"
<< reader.errorString() << "'";
return frames;
}
@ -127,8 +126,8 @@ namespace detail {
if (frames.size() == 0)
{
log("Error while reading image {}: '{}'", url.string,
reader.errorString());
qDebug() << "Error while reading image" << url.string << ": '"
<< reader.errorString() << "'";
}
return frames;

View file

@ -5,7 +5,6 @@
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
#include "messages/ImageSet.hpp"

View file

@ -1,7 +1,6 @@
#include "providers/emoji/Emojis.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "singletons/Settings.hpp"
@ -132,8 +131,9 @@ void Emojis::loadEmojis()
if (result.Code() != rapidjson::kParseErrorNone)
{
log("JSON parse error: {} ({})",
rapidjson::GetParseError_En(result.Code()), result.Offset());
qDebug() << "JSON parse error:"
<< rapidjson::GetParseError_En(result.Code()) << "("
<< result.Offset() << ")";
return;
}
@ -165,8 +165,8 @@ void Emojis::loadEmojis()
auto toneNameIt = toneNames.find(tone);
if (toneNameIt == toneNames.end())
{
log("Tone with key {} does not exist in tone names map",
tone);
qDebug() << "Tone with key" << tone.c_str()
<< "does not exist in tone names map";
continue;
}

View file

@ -4,7 +4,6 @@
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
@ -186,7 +185,8 @@ void FfzEmotes::loadChannel(
const QString &channelId, std::function<void(EmoteMap &&)> emoteCallback,
std::function<void(boost::optional<EmotePtr>)> modBadgeCallback)
{
log("[FFZEmotes] Reload FFZ Channel Emotes for channel {}\n", channelId);
qDebug() << "[FFZEmotes] Reload FFZ Channel Emotes for channel"
<< channelId;
NetworkRequest("https://api.frankerfacez.com/v1/room/id/" + channelId)
@ -211,13 +211,13 @@ void FfzEmotes::loadChannel(
else if (result.status() == NetworkResult::timedoutStatus)
{
// TODO: Auto retry in case of a timeout, with a delay
log("Fetching FFZ emotes for channel {} failed due to timeout",
channelId);
qDebug() << "Fetching FFZ emotes for channel" << channelId
<< "failed due to timeout";
}
else
{
log("Error fetching FFZ emotes for channel {}, error {}",
channelId, result.status());
qDebug() << "Error fetching FFZ emotes for channel" << channelId
<< ", error" << result.status();
}
})
.execute();

View file

@ -2,7 +2,6 @@
#include "common/Channel.hpp"
#include "common/Common.hpp"
#include "debug/Log.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
@ -66,7 +65,7 @@ AbstractIrcServer::AbstractIrcServer()
if (!this->readConnection_->isConnected())
{
log("Trying to reconnect... {}", this->falloffCounter_);
qDebug() << "Trying to reconnect..." << this->falloffCounter_;
this->connect();
}
});
@ -159,23 +158,24 @@ ChannelPtr AbstractIrcServer::getOrAddChannel(const QString &dirtyChannelName)
}
this->channels.insert(channelName, chan);
this->connections_.emplace_back(chan->destroyed.connect([this,
channelName] {
// fourtf: issues when the server itself is destroyed
this->connections_.emplace_back(
chan->destroyed.connect([this, channelName] {
// fourtf: issues when the server itself is destroyed
log("[AbstractIrcServer::addChannel] {} was destroyed", channelName);
this->channels.remove(channelName);
qDebug() << "[AbstractIrcServer::addChannel]" << channelName
<< "was destroyed";
this->channels.remove(channelName);
if (this->readConnection_)
{
this->readConnection_->sendRaw("PART #" + channelName);
}
if (this->readConnection_)
{
this->readConnection_->sendRaw("PART #" + channelName);
}
if (this->writeConnection_ && this->hasSeparateWriteConnection())
{
this->writeConnection_->sendRaw("PART #" + channelName);
}
}));
if (this->writeConnection_ && this->hasSeparateWriteConnection())
{
this->writeConnection_->sendRaw("PART #" + channelName);
}
}));
// join irc channel
{

View file

@ -3,7 +3,6 @@
#include "Application.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/highlights/HighlightController.hpp"
#include "debug/Log.hpp"
#include "messages/LimitedQueue.hpp"
#include "messages/Message.hpp"
#include "providers/twitch/TwitchAccountManager.hpp"
@ -235,9 +234,8 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
if (chan->isEmpty())
{
log("[IrcMessageHandler:handleClearChatMessage] Twitch channel {} not "
"found",
chanName);
qDebug() << "[IrcMessageHandler:handleClearChatMessage] Twitch channel"
<< chanName << "not found";
return;
}
@ -300,10 +298,9 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)
if (chan->isEmpty())
{
log("[IrcMessageHandler:handleClearMessageMessage] Twitch channel {} "
"not "
"found",
chanName);
qDebug()
<< "[IrcMessageHandler:handleClearMessageMessage] Twitch channel"
<< chanName << "not found";
return;
}
@ -356,7 +353,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
{
auto app = getApp();
log("Received whisper!");
qDebug() << "Received whisper!";
MessageParseArgs args;
args.isReceivedWhisper = true;
@ -568,10 +565,8 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
if (channel->isEmpty())
{
log("[IrcManager:handleNoticeMessage] Channel {} not found in "
"channel "
"manager ",
channelName);
qDebug() << "[IrcManager:handleNoticeMessage] Channel"
<< channelName << "not found in channel manager";
return;
}

View file

@ -2,7 +2,6 @@
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchCommon.hpp"
#include <QJsonArray>
@ -39,31 +38,30 @@ void PartialTwitchUser::getId(std::function<void(QString)> successCallback,
auto root = result.parseJson();
if (!root.value("users").isArray())
{
log("API Error while getting user id, users is not an array");
qDebug()
<< "API Error while getting user id, users is not an array";
return Failure;
}
auto users = root.value("users").toArray();
if (users.size() != 1)
{
log("API Error while getting user id, users array size is not "
"1");
qDebug() << "API Error while getting user id, users array size "
"is not 1";
return Failure;
}
if (!users[0].isObject())
{
log("API Error while getting user id, first user is not an "
"object");
qDebug() << "API Error while getting user id, first user is "
"not an object";
return Failure;
}
auto firstUser = users[0].toObject();
auto id = firstUser.value("_id");
if (!id.isString())
{
log("API Error: while getting user id, first user object `_id` "
"key "
"is not a "
"string");
qDebug() << "API Error: while getting user id, first user "
"object `_id` key is not a string";
return Failure;
}
successCallback(id.toString());

View file

@ -1,8 +1,8 @@
#include "providers/twitch/PubsubClient.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/PubsubActions.hpp"
#include "providers/twitch/PubsubHelpers.hpp"
#include "util/Helpers.hpp"
#include "util/RapidjsonHelpers.hpp"
#include <rapidjson/error/en.h>
@ -77,14 +77,14 @@ namespace detail {
return true;
}
void PubSubClient::unlistenPrefix(const std::string &prefix)
void PubSubClient::unlistenPrefix(const QString &prefix)
{
std::vector<std::string> topics;
std::vector<QString> topics;
for (auto it = this->listeners_.begin(); it != this->listeners_.end();)
{
const auto &listener = *it;
if (listener.topic.find(prefix) == 0)
if (listener.topic.startsWith(prefix))
{
topics.push_back(listener.topic);
it = this->listeners_.erase(it);
@ -116,16 +116,14 @@ namespace detail {
{
assert(this->awaitingPong_);
log("Got pong!");
this->awaitingPong_ = false;
}
bool PubSubClient::isListeningToTopic(const std::string &payload)
bool PubSubClient::isListeningToTopic(const QString &topic)
{
for (const auto &listener : this->listeners_)
{
if (listener.topic == payload)
if (listener.topic == topic)
{
return true;
}
@ -156,9 +154,8 @@ namespace detail {
if (self->awaitingPong_)
{
log("No pong response, disconnect!");
// TODO(pajlada): Label this connection as "disconnect
// me"
qDebug() << "No pong response, disconnect!";
// TODO(pajlada): Label this connection as "disconnect me"
}
});
@ -181,7 +178,8 @@ namespace detail {
if (ec)
{
log("Error sending message {}: {}", payload, ec.message());
qDebug() << "Error sending message" << payload << ":"
<< ec.message().c_str();
// TODO(pajlada): Check which error code happened and maybe
// gracefully handle it
@ -223,7 +221,7 @@ PubSub::PubSub()
if (!data.HasMember("args"))
{
log("Missing required args member");
qDebug() << "Missing required args member";
return;
}
@ -231,13 +229,13 @@ PubSub::PubSub()
if (!args.IsArray())
{
log("args member must be an array");
qDebug() << "args member must be an array";
return;
}
if (args.Size() == 0)
{
log("Missing duration argument in slowmode on");
qDebug() << "Missing duration argument in slowmode on";
return;
}
@ -245,7 +243,7 @@ PubSub::PubSub()
if (!durationArg.IsString())
{
log("Duration arg must be a string");
qDebug() << "Duration arg must be a string";
return;
}
@ -338,7 +336,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
action.modded = false;
@ -368,7 +366,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
action.modded = true;
@ -417,7 +415,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@ -454,7 +452,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@ -485,7 +483,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@ -516,7 +514,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@ -568,7 +566,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@ -597,7 +595,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@ -626,7 +624,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@ -655,7 +653,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@ -685,7 +683,7 @@ PubSub::PubSub()
}
catch (const std::runtime_error &ex)
{
log("Error parsing moderation action: {}", ex.what());
qDebug() << "Error parsing moderation action:" << ex.what();
}
};
@ -738,7 +736,7 @@ void PubSub::addClient()
if (ec)
{
log("Unable to establish connection: {}", ec.message());
qDebug() << "Unable to establish connection:" << ec.message().c_str();
return;
}
@ -753,20 +751,23 @@ void PubSub::start()
void PubSub::listenToWhispers(std::shared_ptr<TwitchAccount> account)
{
static const QString topicFormat("whispers.%1");
assert(account != nullptr);
std::string userID = account->getUserId().toStdString();
auto userID = account->getUserId();
log("Connection open!");
qDebug() << "Connection open!";
websocketpp::lib::error_code ec;
std::vector<std::string> topics({"whispers." + userID});
std::vector<QString> topics({topicFormat.arg(userID)});
this->listen(createListenMessage(topics, account));
if (ec)
{
log("Unable to send message to websocket server: {}", ec.message());
qDebug() << "Unable to send message to websocket server:"
<< ec.message().c_str();
return;
}
}
@ -783,26 +784,26 @@ void PubSub::unlistenAllModerationActions()
void PubSub::listenToChannelModerationActions(
const QString &channelID, std::shared_ptr<TwitchAccount> account)
{
static const QString topicFormat("chat_moderator_actions.%1.%2");
assert(!channelID.isEmpty());
assert(account != nullptr);
QString userID = account->getUserId();
if (userID.isEmpty())
return;
std::string topic(fS("chat_moderator_actions.{}.{}", userID, channelID));
auto topic = topicFormat.arg(userID).arg(channelID);
if (this->isListeningToTopic(topic))
{
log("We are already listening to topic {}", topic);
return;
}
log("Listen to topic {}", topic);
qDebug() << "Listen to topic" << topic;
this->listenToTopic(topic, account);
}
void PubSub::listenToTopic(const std::string &topic,
void PubSub::listenToTopic(const QString &topic,
std::shared_ptr<TwitchAccount> account)
{
auto message = createListenMessage({topic}, account);
@ -814,20 +815,19 @@ void PubSub::listen(rapidjson::Document &&msg)
{
if (this->tryListen(msg))
{
log("Successfully listened!");
return;
}
this->addClient();
log("Added to the back of the queue");
qDebug() << "Added to the back of the queue";
this->requests.emplace_back(
std::make_unique<rapidjson::Document>(std::move(msg)));
}
bool PubSub::tryListen(rapidjson::Document &msg)
{
log("tryListen with {} clients", this->clients.size());
qDebug() << "tryListen with" << this->clients.size() << "clients";
for (const auto &p : this->clients)
{
const auto &client = p.second;
@ -840,7 +840,7 @@ bool PubSub::tryListen(rapidjson::Document &msg)
return false;
}
bool PubSub::isListeningToTopic(const std::string &topic)
bool PubSub::isListeningToTopic(const QString &topic)
{
for (const auto &p : this->clients)
{
@ -865,24 +865,24 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
if (!res)
{
log("Error parsing message '{}' from PubSub: {}", payload,
rapidjson::GetParseError_En(res.Code()));
qDebug() << "Error parsing message '" << payload.c_str()
<< "' from PubSub:" << rapidjson::GetParseError_En(res.Code());
return;
}
if (!msg.IsObject())
{
log("Error parsing message '{}' from PubSub. Root object is not an "
"object",
payload);
qDebug() << "Error parsing message '" << payload.c_str()
<< "' from PubSub. Root object is not an "
"object";
return;
}
std::string type;
QString type;
if (!rj::getSafe(msg, "type", type))
{
log("Missing required string member `type` in message root");
qDebug() << "Missing required string member `type` in message root";
return;
}
@ -894,7 +894,7 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
{
if (!msg.HasMember("data"))
{
log("Missing required object member `data` in message root");
qDebug() << "Missing required object member `data` in message root";
return;
}
@ -902,7 +902,7 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
if (!data.IsObject())
{
log("Member `data` must be an object");
qDebug() << "Member `data` must be an object";
return;
}
@ -922,7 +922,7 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl,
}
else
{
log("Unknown message type: {}", type);
qDebug() << "Unknown message type:" << type;
}
}
@ -983,7 +983,7 @@ PubSub::WebsocketContextPtr PubSub::onTLSInit(websocketpp::connection_hdl hdl)
}
catch (const std::exception &e)
{
log("Exception caught in OnTLSInit: {}", e.what());
qDebug() << "Exception caught in OnTLSInit:" << e.what();
}
return ctx;
@ -991,21 +991,21 @@ PubSub::WebsocketContextPtr PubSub::onTLSInit(websocketpp::connection_hdl hdl)
void PubSub::handleListenResponse(const rapidjson::Document &msg)
{
std::string error;
QString error;
if (rj::getSafe(msg, "error", error))
{
std::string nonce;
QString nonce;
rj::getSafe(msg, "nonce", nonce);
if (error.empty())
if (error.isEmpty())
{
log("Successfully listened to nonce {}", nonce);
qDebug() << "Successfully listened to nonce" << nonce;
// Nothing went wrong
return;
}
log("PubSub error: {} on nonce {}", error, nonce);
qDebug() << "PubSub error:" << error << "on nonce" << nonce;
return;
}
}
@ -1016,7 +1016,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
if (!rj::getSafe(outerData, "topic", topic))
{
log("Missing required string member `topic` in outerData");
qDebug() << "Missing required string member `topic` in outerData";
return;
}
@ -1024,7 +1024,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
if (!rj::getSafe(outerData, "message", payload))
{
log("Expected string message in outerData");
qDebug() << "Expected string message in outerData";
return;
}
@ -1034,8 +1034,8 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
if (!res)
{
log("Error parsing message '{}' from PubSub: {}", payload,
rapidjson::GetParseError_En(res.Code()));
qDebug() << "Error parsing message '" << payload.c_str()
<< "' from PubSub:" << rapidjson::GetParseError_En(res.Code());
return;
}
@ -1045,7 +1045,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
if (!rj::getSafe(msg, "type", whisperType))
{
log("Bad whisper data");
qDebug() << "Bad whisper data";
return;
}
@ -1063,7 +1063,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
}
else
{
log("Invalid whisper type: {}", whisperType);
qDebug() << "Invalid whisper type:" << whisperType.c_str();
assert(false);
return;
}
@ -1078,7 +1078,8 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
if (!rj::getSafe(data, "moderation_action", moderationAction))
{
log("Missing moderation action in data: {}", rj::stringify(data));
qDebug() << "Missing moderation action in data:"
<< rj::stringify(data).c_str();
return;
}
@ -1086,7 +1087,8 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
if (handlerIt == this->moderationActionHandlers.end())
{
log("No handler found for moderation action {}", moderationAction);
qDebug() << "No handler found for moderation action"
<< moderationAction.c_str();
return;
}
@ -1095,16 +1097,16 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
}
else
{
log("Unknown topic: {}", topic);
qDebug() << "Unknown topic:" << topic;
return;
}
}
void PubSub::runThread()
{
log("Start pubsub manager thread");
qDebug() << "Start pubsub manager thread";
this->websocketClient.run();
log("Done with pubsub manager thread");
qDebug() << "Done with pubsub manager thread";
}
} // namespace chatterino

View file

@ -15,7 +15,6 @@
#include <map>
#include <memory>
#include <set>
#include <string>
#include <thread>
#include <unordered_map>
#include <vector>
@ -33,7 +32,7 @@ using WebsocketErrorCode = websocketpp::lib::error_code;
namespace detail {
struct Listener {
std::string topic;
QString topic;
bool authed;
bool persistent;
bool confirmed = false;
@ -49,11 +48,11 @@ namespace detail {
void stop();
bool listen(rapidjson::Document &message);
void unlistenPrefix(const std::string &prefix);
void unlistenPrefix(const QString &prefix);
void handlePong();
bool isListeningToTopic(const std::string &topic);
bool isListeningToTopic(const QString &topic);
private:
void ping();
@ -135,13 +134,13 @@ public:
std::vector<std::unique_ptr<rapidjson::Document>> requests;
private:
void listenToTopic(const std::string &topic,
void listenToTopic(const QString &topic,
std::shared_ptr<TwitchAccount> account);
void listen(rapidjson::Document &&msg);
bool tryListen(rapidjson::Document &msg);
bool isListeningToTopic(const std::string &topic);
bool isListeningToTopic(const QString &topic);
void addClient();

View file

@ -46,9 +46,8 @@ bool getTargetUser(const rapidjson::Value &data, ActionUser &user)
return rj::getSafe(data, "target_user_id", user.id);
}
rapidjson::Document createListenMessage(
const std::vector<std::string> &topicsVec,
std::shared_ptr<TwitchAccount> account)
rapidjson::Document createListenMessage(const std::vector<QString> &topicsVec,
std::shared_ptr<TwitchAccount> account)
{
rapidjson::Document msg(rapidjson::kObjectType);
auto &a = msg.GetAllocator();
@ -75,8 +74,7 @@ rapidjson::Document createListenMessage(
return msg;
}
rapidjson::Document createUnlistenMessage(
const std::vector<std::string> &topicsVec)
rapidjson::Document createUnlistenMessage(const std::vector<QString> &topicsVec)
{
rapidjson::Document msg(rapidjson::kObjectType);
auto &a = msg.GetAllocator();

View file

@ -3,7 +3,6 @@
#include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <memory>
#include "debug/Log.hpp"
#include "util/RapidjsonHelpers.hpp"
namespace chatterino {
@ -18,11 +17,10 @@ bool getCreatedByUser(const rapidjson::Value &data, ActionUser &user);
bool getTargetUser(const rapidjson::Value &data, ActionUser &user);
rapidjson::Document createListenMessage(
const std::vector<std::string> &topicsVec,
std::shared_ptr<TwitchAccount> account);
rapidjson::Document createListenMessage(const std::vector<QString> &topicsVec,
std::shared_ptr<TwitchAccount> account);
rapidjson::Document createUnlistenMessage(
const std::vector<std::string> &topicsVec);
const std::vector<QString> &topicsVec);
// Create timer using given ioService
template <typename Duration, typename Callback>
@ -35,7 +33,7 @@ void runAfter(boost::asio::io_service &ioService, Duration duration,
timer->async_wait([timer, cb](const boost::system::error_code &ec) {
if (ec)
{
log("Error in runAfter: {}", ec.message());
qDebug() << "Error in runAfter:" << ec.message().c_str();
return;
}
@ -53,7 +51,7 @@ void runAfter(std::shared_ptr<boost::asio::steady_timer> timer,
timer->async_wait([timer, cb](const boost::system::error_code &ec) {
if (ec)
{
log("Error in runAfter: {}", ec.message());
qDebug() << "Error in runAfter:" << ec.message().c_str();
return;
}

View file

@ -6,7 +6,6 @@
#include "common/Env.hpp"
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/PartialTwitchUser.hpp"
#include "providers/twitch/TwitchCommon.hpp"
#include "singletons/Emotes.hpp"
@ -134,8 +133,8 @@ void TwitchAccount::loadIgnores()
TwitchUser ignoredUser;
if (!rj::getSafe(userIt->value, ignoredUser))
{
log("Error parsing twitch user JSON {}",
rj::stringify(userIt->value));
qDebug() << "Error parsing twitch user JSON"
<< rj::stringify(userIt->value).c_str();
continue;
}
@ -345,14 +344,14 @@ std::set<TwitchUser> TwitchAccount::getIgnores() const
void TwitchAccount::loadEmotes()
{
log("Loading Twitch emotes for user {}", this->getUserName());
qDebug() << "Loading Twitch emotes for user" << this->getUserName();
const auto &clientID = this->getOAuthClient();
const auto &oauthToken = this->getOAuthToken();
if (clientID.isEmpty() || oauthToken.isEmpty())
{
log("Missing Client ID or OAuth token");
qDebug() << "Missing Client ID or OAuth token";
return;
}
@ -363,7 +362,7 @@ void TwitchAccount::loadEmotes()
.authorizeTwitchV5(this->getOAuthClient(), this->getOAuthToken())
.onError([=](NetworkResult result) {
log("[TwitchAccount::loadEmotes] Error {}", result.status());
qDebug() << "[TwitchAccount::loadEmotes] Error" << result.status();
if (result.status() == 203)
{
// onFinished(FollowResult_NotFollowing);
@ -402,7 +401,8 @@ void TwitchAccount::autoModAllow(const QString msgID)
.authorizeTwitchV5(this->getOAuthClient(), this->getOAuthToken())
.onError([=](NetworkResult result) {
log("[TwitchAccounts::autoModAllow] Error {}", result.status());
qDebug() << "[TwitchAccounts::autoModAllow] Error"
<< result.status();
})
.execute();
}
@ -421,7 +421,8 @@ void TwitchAccount::autoModDeny(const QString msgID)
.authorizeTwitchV5(this->getOAuthClient(), this->getOAuthToken())
.onError([=](NetworkResult result) {
log("[TwitchAccounts::autoModDeny] Error {}", result.status());
qDebug() << "[TwitchAccounts::autoModDeny] Error"
<< result.status();
})
.execute();
}
@ -436,7 +437,7 @@ void TwitchAccount::parseEmotes(const rapidjson::Document &root)
auto emoticonSets = root.FindMember("emoticon_sets");
if (emoticonSets == root.MemberEnd() || !emoticonSets->value.IsObject())
{
log("No emoticon_sets in load emotes response");
qDebug() << "No emoticon_sets in load emotes response";
return;
}
@ -452,21 +453,21 @@ void TwitchAccount::parseEmotes(const rapidjson::Document &root)
{
if (!emoteJSON.IsObject())
{
log("Emote value was invalid");
qDebug() << "Emote value was invalid";
return;
}
uint64_t idNumber;
if (!rj::getSafe(emoteJSON, "id", idNumber))
{
log("No ID key found in Emote value");
qDebug() << "No ID key found in Emote value";
return;
}
QString _code;
if (!rj::getSafe(emoteJSON, "code", _code))
{
log("No code key found in Emote value");
qDebug() << "No code key found in Emote value";
return;
}
@ -489,7 +490,7 @@ void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
{
if (!emoteSet)
{
log("null emote set sent");
qDebug() << "null emote set sent";
return;
}
@ -505,7 +506,8 @@ void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
NetworkRequest(Env::get().twitchEmoteSetResolverUrl.arg(emoteSet->key))
.cache()
.onError([](NetworkResult result) {
log("Error code {} while loading emote set data", result.status());
qDebug() << "Error code" << result.status()
<< "while loading emote set data";
})
.onSuccess([emoteSet](auto result) -> Outcome {
auto root = result.parseRapidJson();
@ -527,7 +529,7 @@ void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
return Failure;
}
log("Loaded twitch emote set data for {}!", emoteSet->key);
qDebug() << "Loaded twitch emote set data for" << emoteSet->key;
auto name = channelName;
name.detach();

View file

@ -1,7 +1,6 @@
#include "providers/twitch/TwitchAccountManager.hpp"
#include "common/Common.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "providers/twitch/TwitchCommon.hpp"
@ -103,23 +102,23 @@ void TwitchAccountManager::reloadUsers()
switch (this->addUser(userData))
{
case AddUserResponse::UserAlreadyExists: {
log("User {} already exists", userData.username);
qDebug() << "User" << userData.username << "already exists";
// Do nothing
}
break;
case AddUserResponse::UserValuesUpdated: {
log("User {} already exists, and values updated!",
userData.username);
qDebug() << "User" << userData.username
<< "already exists, and values updated!";
if (userData.username == this->getCurrent()->getUserName())
{
log("It was the current user, so we need to reconnect "
"stuff!");
qDebug() << "It was the current user, so we need to "
"reconnect stuff!";
this->currentUserChanged.invoke();
}
}
break;
case AddUserResponse::UserAdded: {
log("Added user {}", userData.username);
qDebug() << "Added user" << userData.username;
listUpdated = true;
}
break;
@ -140,15 +139,12 @@ void TwitchAccountManager::load()
auto user = this->findUserByUsername(newUsername);
if (user)
{
log("[AccountManager:currentUsernameChanged] User successfully "
"updated to {}",
newUsername);
qDebug() << "Twitch user updated to" << newUsername;
this->currentUser_ = user;
}
else
{
log("[AccountManager:currentUsernameChanged] User successfully "
"updated to anonymous");
qDebug() << "Twitch user updated to anonymous";
this->currentUser_ = this->anonymousUser_;
}
@ -170,11 +166,13 @@ bool TwitchAccountManager::isLoggedIn() const
bool TwitchAccountManager::removeUser(TwitchAccount *account)
{
static const QString accountFormat("/accounts/uid%1");
auto userID(account->getUserId());
if (!userID.isEmpty())
{
pajlada::Settings::SettingManager::removeSetting(
fS("/accounts/uid{}", userID));
accountFormat.arg(userID).toStdString());
}
if (account->getUserName() == this->currentUsername)

View file

@ -2,7 +2,6 @@
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/TwitchCommon.hpp"
#include <QString>
@ -23,22 +22,23 @@ void TwitchApi::findUserId(const QString user,
auto root = result.parseJson();
if (!root.value("users").isArray())
{
log("API Error while getting user id, users is not an array");
qDebug()
<< "API Error while getting user id, users is not an array";
successCallback("");
return Failure;
}
auto users = root.value("users").toArray();
if (users.size() != 1)
{
log("API Error while getting user id, users array size is not "
"1");
qDebug() << "API Error while getting user id, users array size "
"is not 1";
successCallback("");
return Failure;
}
if (!users[0].isObject())
{
log("API Error while getting user id, first user is not an "
"object");
qDebug() << "API Error while getting user id, first user is "
"not an object";
successCallback("");
return Failure;
}
@ -46,10 +46,8 @@ void TwitchApi::findUserId(const QString user,
auto id = firstUser.value("_id");
if (!id.isString())
{
log("API Error: while getting user id, first user object `_id` "
"key "
"is not a "
"string");
qDebug() << "API Error: while getting user id, first user "
"object `_id` key is not a string";
successCallback("");
return Failure;
}
@ -73,8 +71,8 @@ void TwitchApi::findUserName(const QString userid,
auto name = root.value("name");
if (!name.isString())
{
log("API Error: while getting user name, `name` is not a "
"string");
qDebug() << "API Error: while getting user name, `name` is not "
"a string";
successCallback("");
return Failure;
}

View file

@ -7,7 +7,6 @@
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
namespace chatterino {

View file

@ -6,7 +6,6 @@
#include "common/NetworkRequest.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/notifications/NotificationController.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/bttv/LoadBttvChannelEmote.hpp"
@ -92,7 +91,7 @@ TwitchChannel::TwitchChannel(const QString &name,
, mod_(false)
, titleRefreshedTime_(QTime::currentTime().addSecs(-TITLE_REFRESH_PERIOD))
{
log("[TwitchChannel:{}] Opened", name);
qDebug() << "[TwitchChannel" << name << "] Opened";
this->liveStatusChanged.connect([this]() {
if (this->isLive() == 1)
@ -194,7 +193,8 @@ void TwitchChannel::sendMessage(const QString &message)
return;
}
log("[TwitchChannel:{}] Send message: {}", this->getName(), message);
qDebug() << "[TwitchChannel" << this->getName()
<< "] Send message:" << message;
// Do last message processing
QString parsedMessage = app->emotes->emojis.replaceShortCodes(message);
@ -491,8 +491,8 @@ void TwitchChannel::refreshLiveStatus()
if (roomID.isEmpty())
{
log("[TwitchChannel:{}] Refreshing live status (Missing ID)",
this->getName());
qDebug() << "[TwitchChannel" << this->getName()
<< "] Refreshing live status (Missing ID)";
this->setLive(false);
return;
}
@ -517,13 +517,13 @@ Outcome TwitchChannel::parseLiveStatus(const rapidjson::Document &document)
{
if (!document.IsObject())
{
log("[TwitchChannel:refreshLiveStatus] root is not an object");
qDebug() << "[TwitchChannel:refreshLiveStatus] root is not an object";
return Failure;
}
if (!document.HasMember("stream"))
{
log("[TwitchChannel:refreshLiveStatus] Missing stream in root");
qDebug() << "[TwitchChannel:refreshLiveStatus] Missing stream in root";
return Failure;
}
@ -539,7 +539,8 @@ Outcome TwitchChannel::parseLiveStatus(const rapidjson::Document &document)
if (!stream.HasMember("viewers") || !stream.HasMember("game") ||
!stream.HasMember("channel") || !stream.HasMember("created_at"))
{
log("[TwitchChannel:refreshLiveStatus] Missing members in stream");
qDebug()
<< "[TwitchChannel:refreshLiveStatus] Missing members in stream";
this->setLive(false);
return Failure;
}
@ -548,8 +549,8 @@ Outcome TwitchChannel::parseLiveStatus(const rapidjson::Document &document)
if (!streamChannel.IsObject() || !streamChannel.HasMember("status"))
{
log("[TwitchChannel:refreshLiveStatus] Missing member \"status\" in "
"channel");
qDebug() << "[TwitchChannel:refreshLiveStatus] Missing member "
"\"status\" in channel";
return Failure;
}
@ -836,7 +837,7 @@ boost::optional<CheerEmote> TwitchChannel::cheerEmote(const QString &string)
int bitAmount = amount.toInt(&ok);
if (!ok)
{
log("Error parsing bit amount in cheerEmote");
qDebug() << "Error parsing bit amount in cheerEmote";
}
for (const auto &emote : set.cheerEmotes)
{

View file

@ -2,7 +2,6 @@
#include "common/NetworkRequest.hpp"
#include "debug/Benchmark.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
#include "util/RapidjsonHelpers.hpp"

View file

@ -1,5 +1,4 @@
#include "providers/twitch/TwitchHelpers.hpp"
#include "debug/Log.hpp"
namespace chatterino {
@ -7,7 +6,7 @@ bool trimChannelName(const QString &channelName, QString &outChannelName)
{
if (channelName.length() < 2)
{
log("channel name length below 2");
qDebug() << "channel name length below 2";
return false;
}

View file

@ -5,7 +5,6 @@
#include "controllers/highlights/HighlightController.hpp"
#include "controllers/ignores/IgnoreController.hpp"
#include "controllers/pings/PingController.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "providers/chatterino/ChatterinoBadges.hpp"
#include "providers/twitch/TwitchBadges.hpp"
@ -90,8 +89,6 @@ namespace {
QStringList parts = badgeInfo.split('/');
if (parts.size() != 2)
{
log("Skipping badge-info because it split weird: {}",
badgeInfo);
continue;
}
@ -110,7 +107,6 @@ namespace {
QStringList parts = badge.split('/');
if (parts.size() != 2)
{
log("Skipping badge because it split weird: {}", badge);
continue;
}
@ -159,8 +155,8 @@ bool TwitchMessageBuilder::isIgnored() const
{
if (phrase.isBlock() && phrase.isMatch(this->originalMessage_))
{
log("Blocking message because it contains ignored phrase {}",
phrase.getPattern());
qDebug() << "Blocking message because it contains ignored phrase"
<< phrase.getPattern();
return true;
}
}
@ -190,8 +186,8 @@ bool TwitchMessageBuilder::isIgnored() const
case ShowIgnoredUsersMessages::Never:
break;
}
log("Blocking message because it's from blocked user {}",
user.name);
qDebug() << "Blocking message because it's from blocked user"
<< user.name;
return true;
}
}
@ -427,8 +423,8 @@ void TwitchMessageBuilder::addWords(
auto emoteImage = std::get<1>(*currentTwitchEmote);
if (emoteImage == nullptr)
{
log("emoteImage nullptr {}",
std::get<2>(*currentTwitchEmote).string);
qDebug() << "emoteImage nullptr"
<< std::get<2>(*currentTwitchEmote).string;
}
this->emplace<EmoteElement>(emoteImage,
MessageElementFlag::TwitchEmote);
@ -771,7 +767,7 @@ void TwitchMessageBuilder::runIgnoreReplaces(
{
if (std::get<1>(*copy) == nullptr)
{
log("remem nullptr {}", std::get<2>(*copy).string);
qDebug() << "remem nullptr" << std::get<2>(*copy).string;
}
}
std::vector<std::tuple<int, EmotePtr, EmoteName>> v(
@ -809,7 +805,7 @@ void TwitchMessageBuilder::runIgnoreReplaces(
{
if (emote.second == nullptr)
{
log("emote null {}", emote.first.string);
qDebug() << "emote null" << emote.first.string;
}
twitchEmotes.push_back(std::tuple<int, EmotePtr, EmoteName>{
startIndex + pos, emote.second, emote.first});
@ -872,7 +868,7 @@ void TwitchMessageBuilder::runIgnoreReplaces(
{
if (std::get<1>(tup) == nullptr)
{
log("v nullptr {}", std::get<2>(tup).string);
qDebug() << "v nullptr" << std::get<2>(tup).string;
continue;
}
QRegularExpression emoteregex(
@ -941,7 +937,7 @@ void TwitchMessageBuilder::runIgnoreReplaces(
{
if (std::get<1>(tup) == nullptr)
{
log("v nullptr {}", std::get<2>(tup).string);
qDebug() << "v nullptr" << std::get<2>(tup).string;
continue;
}
QRegularExpression emoteregex(
@ -991,8 +987,8 @@ void TwitchMessageBuilder::parseHighlights()
{
continue;
}
log("Highlight because user {} sent a message",
this->ircMessage->nick());
qDebug() << "Highlight because user" << this->ircMessage->nick()
<< "sent a message";
if (!this->highlightVisual_)
{
this->highlightVisual_ = true;
@ -1044,8 +1040,8 @@ void TwitchMessageBuilder::parseHighlights()
continue;
}
log("Highlight because {} matches {}", this->originalMessage_,
highlight.getPattern());
qDebug() << "Highlight because" << this->originalMessage_ << "matches"
<< highlight.getPattern();
if (!this->highlightVisual_)
{
this->highlightVisual_ = true;
@ -1130,7 +1126,7 @@ void TwitchMessageBuilder::appendTwitchEmote(
start, app->emotes->twitch.getOrCreateEmote(id, name), name};
if (std::get<1>(tup) == nullptr)
{
log("nullptr {}", std::get<2>(tup).string);
qDebug() << "nullptr" << std::get<2>(tup).string;
}
vec.push_back(std::move(tup));
}
@ -1216,7 +1212,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
auto badgeEmote = this->getTwitchBadge(badge);
if (!badgeEmote)
{
log("No channel/global variant found {}", badge.key_);
qDebug() << "No channel/global variant found" << badge.key_;
continue;
}
auto tooltip = (*badgeEmote)->tooltip.string;

View file

@ -1,7 +1,6 @@
#include "singletons/Logging.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"

View file

@ -1,7 +1,6 @@
#include "singletons/Settings.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "singletons/Paths.hpp"
#include "singletons/Resources.hpp"
#include "singletons/WindowManager.hpp"

View file

@ -13,7 +13,6 @@
#include "Application.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "debug/Log.hpp"
#include "messages/MessageElement.hpp"
#include "providers/irc/Irc2.hpp"
#include "providers/irc/IrcChannel2.hpp"
@ -264,7 +263,7 @@ Window *WindowManager::windowAt(int index)
{
return nullptr;
}
log("getting window at bad index {}", index);
qDebug() << "getting window at bad index" << index;
return this->windows_.at(index);
}
@ -432,7 +431,7 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
void WindowManager::save()
{
log("[WindowManager] Saving");
qDebug() << "[WindowManager] Saving";
assertInGuiThread();
QJsonDocument document;

View file

@ -1,7 +1,6 @@
#include "LoggingChannel.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"
@ -64,13 +63,13 @@ void LoggingChannel::openLogFile()
if (!QDir().mkpath(directory))
{
log("Unable to create logging path");
qDebug() << "Unable to create logging path";
return;
}
// Open file handle to log file of current date
QString fileName = directory + QDir::separator() + baseFileName;
log("Logging to {}", fileName);
qDebug() << "Logging to" << fileName;
this->fileHandle.setFileName(fileName);
this->fileHandle.open(QIODevice::Append);

View file

@ -1,16 +1,9 @@
#pragma once
#include <fmt/format.h>
#include <QString>
namespace chatterino {
template <typename... Args>
auto fS(Args &&... args)
{
return fmt::format(std::forward<Args>(args)...);
}
QString generateUuid();
QString formatRichLink(const QString &url, bool file = false);
@ -21,13 +14,3 @@ QString formatRichNamedLink(const QString &url, const QString &name,
QString shortenString(const QString &str, unsigned maxWidth = 50);
} // 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

View file

@ -5,8 +5,6 @@
#include <QSettings>
#include <QVariant>
#include "debug/Log.hpp"
namespace chatterino {
namespace {
#ifdef Q_OS_WIN

View file

@ -1,7 +1,6 @@
#include "util/StreamLink.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "singletons/Settings.hpp"
#include "util/Helpers.hpp"
#include "widgets/dialogs/QualityPopup.hpp"
@ -92,7 +91,7 @@ namespace {
}
else
{
log("Error occured {}", err);
qDebug() << "Error occured" << err;
}
p->deleteLater();
@ -119,7 +118,7 @@ void getStreamQualities(const QString &channelURL,
[=](int res) {
if (res != 0)
{
log("Got error code {}", res);
qDebug() << "Got error code" << res;
// return;
}
QString lastLine = QString(p->readAllStandardOutput());

View file

@ -1,5 +1,4 @@
#include "widgets/AccountSwitchPopup.hpp"
#include "debug/Log.hpp"
#include "widgets/dialogs/SettingsDialog.hpp"
#include <QHBoxLayout>

View file

@ -2,7 +2,6 @@
#include "BaseSettings.hpp"
#include "BaseTheme.hpp"
#include "debug/Log.hpp"
#include "widgets/BaseWindow.hpp"
#include <QChildEvent>

View file

@ -3,7 +3,6 @@
#include "BaseSettings.hpp"
#include "BaseTheme.hpp"
#include "boost/algorithm/algorithm.hpp"
#include "debug/Log.hpp"
#include "util/PostToThread.hpp"
#include "util/Shortcut.hpp"
#include "util/WindowsHelper.hpp"
@ -385,7 +384,7 @@ void BaseWindow::mousePressEvent(QMouseEvent *event)
if (!recursiveCheckMouseTracking(widget))
{
log("Start moving");
qDebug() << "Start moving";
this->moving = true;
}
}
@ -402,7 +401,7 @@ void BaseWindow::mouseReleaseEvent(QMouseEvent *event)
{
if (this->moving)
{
log("Stop moving");
qDebug() << "Stop moving";
this->moving = false;
}
}

View file

@ -1,7 +1,6 @@
#include "widgets/Notebook.hpp"
#include "Application.hpp"
#include "debug/Log.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "singletons/WindowManager.hpp"

View file

@ -65,7 +65,7 @@ namespace {
// messageBox.setIcon(QMessageBox::Information);
// messageBox.setText("Successfully logged in with user <b>" +
// qS(username) + "</b>!");
auto basePath = fS("/accounts/uid{}", userID);
std::string basePath = "/accounts/uid" + userID.toStdString();
pajlada::Settings::Setting<QString>::set(basePath + "/username",
username);
pajlada::Settings::Setting<QString>::set(basePath + "/userID", userID);

View file

@ -3,7 +3,6 @@
#include "IrcMessage"
#include "common/Channel.hpp"
#include "common/NetworkRequest.hpp"
#include "debug/Log.hpp"
#include "messages/Message.hpp"
#include "providers/twitch/PartialTwitchUser.hpp"
#include "providers/twitch/TwitchChannel.hpp"
@ -70,7 +69,7 @@ void LogsPopup::getLogs()
return;
}
log("Unable to get logs, no channel name or something specified");
qDebug() << "Unable to get logs, no channel name or something specified";
}
void LogsPopup::setMessages(std::vector<MessagePtr> &messages)

View file

@ -1,5 +1,4 @@
#include "QualityPopup.hpp"
#include "debug/Log.hpp"
#include "util/StreamLink.hpp"
namespace chatterino {
@ -50,7 +49,7 @@ void QualityPopup::okButtonClicked()
}
catch (const Exception &ex)
{
log("Exception caught trying to open streamlink: {}", ex.what());
qDebug() << "Exception caught trying to open streamlink:" << ex.what();
}
this->close();

View file

@ -16,7 +16,6 @@
#include "common/Common.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "debug/Benchmark.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "messages/Message.hpp"
@ -740,9 +739,8 @@ void ChannelView::messageReplaced(size_t index, MessagePtr &replacement)
auto snapshot = this->messages_.getSnapshot();
if (index >= snapshot.size())
{
log("Tried to replace out of bounds message. Index: {}. "
"Length: {}",
index, snapshot.size());
qDebug() << "Tried to replace out of bounds message. Index:" << index
<< ". Length:" << snapshot.size();
return;
}

View file

@ -2,7 +2,6 @@
#include "Application.hpp"
#include "common/Common.hpp"
#include "debug/Log.hpp"
#include "singletons/Fonts.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"

View file

@ -2,7 +2,6 @@
#include "common/Modes.hpp"
#include "common/Version.hpp"
#include "debug/Log.hpp"
#include "util/LayoutCreator.hpp"
#include "util/RemoveScrollAreaBackground.hpp"
#include "widgets/helper/SignalLabel.hpp"
@ -102,8 +101,6 @@ AboutPage::AboutPage()
":/licenses/qt_lgpl-3.0.txt");
addLicense(form.getElement(), "Boost", "https://www.boost.org/",
":/licenses/boost_boost.txt");
addLicense(form.getElement(), "Fmt", "http://fmtlib.net/",
":/licenses/fmt_bsd2.txt");
addLicense(form.getElement(), "LibCommuni",
"https://github.com/communi/libcommuni",
":/licenses/libcommuni_BSD3.txt");
@ -166,7 +163,7 @@ AboutPage::AboutPage()
if (contributorParts.size() != 4)
{
log("Missing parts in line '{}'", line);
qDebug() << "Missing parts in line" << line;
continue;
}

View file

@ -5,7 +5,6 @@
#include "controllers/highlights/HighlightController.hpp"
#include "controllers/highlights/HighlightModel.hpp"
#include "controllers/highlights/UserHighlightModel.hpp"
#include "debug/Log.hpp"
#include "singletons/Settings.hpp"
#include "util/LayoutCreator.hpp"
#include "util/StandardItemHelper.hpp"

View file

@ -3,7 +3,6 @@
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/EmoteValue.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
@ -530,7 +529,7 @@ void Split::openInStreamlink()
}
catch (const Exception &ex)
{
log("Error in doOpenStreamlink: {}", ex.what());
qDebug() << "Error in doOpenStreamlink:" << ex.what();
}
}