Merge pull request #3533 from daniellimws/fmtlib-macros

Logging: Add fmtlib-based macros
This commit is contained in:
Merry 2018-03-24 08:04:20 +00:00 committed by GitHub
commit 174e7e268a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 151 additions and 101 deletions

View file

@ -25,6 +25,7 @@
#include "citra/config.h"
#include "citra/emu_window/emu_window_sdl2.h"
#include "common/common_paths.h"
#include "common/file_util.h"
#include "common/logging/backend.h"
#include "common/logging/filter.h"
@ -67,39 +68,39 @@ static void PrintVersion() {
static void OnStateChanged(const Network::RoomMember::State& state) {
switch (state) {
case Network::RoomMember::State::Idle:
LOG_DEBUG(Network, "Network is idle");
NGLOG_DEBUG(Network, "Network is idle");
break;
case Network::RoomMember::State::Joining:
LOG_DEBUG(Network, "Connection sequence to room started");
NGLOG_DEBUG(Network, "Connection sequence to room started");
break;
case Network::RoomMember::State::Joined:
LOG_DEBUG(Network, "Successfully joined to the room");
NGLOG_DEBUG(Network, "Successfully joined to the room");
break;
case Network::RoomMember::State::LostConnection:
LOG_DEBUG(Network, "Lost connection to the room");
NGLOG_DEBUG(Network, "Lost connection to the room");
break;
case Network::RoomMember::State::CouldNotConnect:
LOG_ERROR(Network, "State: CouldNotConnect");
NGLOG_ERROR(Network, "State: CouldNotConnect");
exit(1);
break;
case Network::RoomMember::State::NameCollision:
LOG_ERROR(
NGLOG_ERROR(
Network,
"You tried to use the same nickname then another user that is connected to the Room");
exit(1);
break;
case Network::RoomMember::State::MacCollision:
LOG_ERROR(Network, "You tried to use the same MAC-Address then another user that is "
"connected to the Room");
NGLOG_ERROR(Network, "You tried to use the same MAC-Address then another user that is "
"connected to the Room");
exit(1);
break;
case Network::RoomMember::State::WrongPassword:
LOG_ERROR(Network, "Room replied with: Wrong password");
NGLOG_ERROR(Network, "Room replied with: Wrong password");
exit(1);
break;
case Network::RoomMember::State::WrongVersion:
LOG_ERROR(Network,
"You are using a different version then the room you are trying to connect to");
NGLOG_ERROR(Network,
"You are using a different version then the room you are trying to connect to");
exit(1);
break;
default:
@ -126,7 +127,7 @@ int main(int argc, char** argv) {
auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w);
if (argv_w == nullptr) {
LOG_CRITICAL(Frontend, "Failed to get command line arguments");
NGLOG_CRITICAL(Frontend, "Failed to get command line arguments");
return -1;
}
#endif
@ -162,7 +163,7 @@ int main(int argc, char** argv) {
break;
case 'i': {
const auto cia_progress = [](size_t written, size_t total) {
LOG_INFO(Frontend, "%02zu%%", (written * 100 / total));
NGLOG_INFO(Frontend, "{:02d}%", (written * 100 / total));
};
if (Service::AM::InstallCIA(std::string(optarg), cia_progress) !=
Service::AM::InstallStatus::Success)
@ -230,23 +231,22 @@ int main(int argc, char** argv) {
LocalFree(argv_w);
#endif
Log::Filter log_filter(Log::Level::Debug);
Log::SetFilter(&log_filter);
MicroProfileOnThreadCreate("EmuThread");
SCOPE_EXIT({ MicroProfileShutdown(); });
if (filepath.empty()) {
LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified");
NGLOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified");
return -1;
}
if (!movie_record.empty() && !movie_play.empty()) {
LOG_CRITICAL(Frontend, "Cannot both play and record a movie");
NGLOG_CRITICAL(Frontend, "Cannot both play and record a movie");
return -1;
}
Log::Filter log_filter;
log_filter.ParseFilterString(Settings::values.log_filter);
Log::SetFilter(&log_filter);
// Apply the command line arguments
Settings::values.gdbstub_port = gdb_port;
@ -265,28 +265,28 @@ int main(int argc, char** argv) {
switch (load_result) {
case Core::System::ResultStatus::ErrorGetLoader:
LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filepath.c_str());
NGLOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filepath);
return -1;
case Core::System::ResultStatus::ErrorLoader:
LOG_CRITICAL(Frontend, "Failed to load ROM!");
NGLOG_CRITICAL(Frontend, "Failed to load ROM!");
return -1;
case Core::System::ResultStatus::ErrorLoader_ErrorEncrypted:
LOG_CRITICAL(Frontend, "The game that you are trying to load must be decrypted before "
"being used with Citra. \n\n For more information on dumping and "
"decrypting games, please refer to: "
"https://citra-emu.org/wiki/dumping-game-cartridges/");
NGLOG_CRITICAL(Frontend, "The game that you are trying to load must be decrypted before "
"being used with Citra. \n\n For more information on dumping and "
"decrypting games, please refer to: "
"https://citra-emu.org/wiki/dumping-game-cartridges/");
return -1;
case Core::System::ResultStatus::ErrorLoader_ErrorInvalidFormat:
LOG_CRITICAL(Frontend, "Error while loading ROM: The ROM format is not supported.");
NGLOG_CRITICAL(Frontend, "Error while loading ROM: The ROM format is not supported.");
return -1;
case Core::System::ResultStatus::ErrorNotInitialized:
LOG_CRITICAL(Frontend, "CPUCore not initialized");
NGLOG_CRITICAL(Frontend, "CPUCore not initialized");
return -1;
case Core::System::ResultStatus::ErrorSystemMode:
LOG_CRITICAL(Frontend, "Failed to determine system mode!");
NGLOG_CRITICAL(Frontend, "Failed to determine system mode!");
return -1;
case Core::System::ResultStatus::ErrorVideoCore:
LOG_CRITICAL(Frontend, "VideoCore not initialized");
NGLOG_CRITICAL(Frontend, "VideoCore not initialized");
return -1;
case Core::System::ResultStatus::Success:
break; // Expected case
@ -298,11 +298,11 @@ int main(int argc, char** argv) {
if (auto member = Network::GetRoomMember().lock()) {
member->BindOnChatMessageRecieved(OnMessageReceived);
member->BindOnStateChanged(OnStateChanged);
LOG_DEBUG(Network, "Start connection to %s:%u with nickname %s", address.c_str(), port,
nickname.c_str());
NGLOG_DEBUG(Network, "Start connection to {}:{} with nickname {}", address, port,
nickname);
member->Join(nickname, address.c_str(), port, 0, Network::NoPreferredMac, password);
} else {
LOG_ERROR(Network, "Could not access RoomMember");
NGLOG_ERROR(Network, "Could not access RoomMember");
return 0;
}
}