From d62c94f14aa5025daee8d3a1d794d43eb1474a83 Mon Sep 17 00:00:00 2001 From: Ted John Date: Wed, 25 May 2016 20:26:12 +0100 Subject: [PATCH] use Console::WriteLine instead of log_info --- src/core/Console.cpp | 9 +++++++-- src/core/Console.hpp | 2 +- src/network/network.cpp | 13 ++++++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/core/Console.cpp b/src/core/Console.cpp index bc0e16c7d7..f1b8c937b2 100644 --- a/src/core/Console.cpp +++ b/src/core/Console.cpp @@ -55,9 +55,14 @@ namespace Console puts(""); } - void WriteLine(const utf8 * str) + void WriteLine(const utf8 * format, ...) { - puts(str); + va_list args; + + va_start(args, format); + vfprintf(stdout, format, args); + puts(""); + va_end(args); } namespace Error diff --git a/src/core/Console.hpp b/src/core/Console.hpp index 0336bf764f..64ac7a765b 100644 --- a/src/core/Console.hpp +++ b/src/core/Console.hpp @@ -28,7 +28,7 @@ namespace Console void WriteSpace(size_t count); void WriteFormat(const utf8 * format, ...); void WriteLine(); - void WriteLine(const utf8 * str); + void WriteLine(const utf8 * format, ...); namespace Error { diff --git a/src/network/network.cpp b/src/network/network.cpp index 670eb541b1..0a4a666a5e 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -32,8 +32,11 @@ extern "C" { #include #include #include -#include "../core/Util.hpp" + +#include "../core/Console.hpp" #include "../core/Json.hpp" +#include "../core/Util.hpp" + extern "C" { #include "../config.h" #include "../game.h" @@ -714,10 +717,10 @@ bool Network::BeginClient(const char* host, unsigned short port) safe_strcat(keyPath, gConfigNetwork.player_name, MAX_PATH); safe_strcat(keyPath, ".privkey", MAX_PATH); if (!platform_file_exists(keyPath)) { - log_info("Generating key... This may take a while"); - log_info("Need to collect enough entropy from the system"); + Console::WriteLine("Generating key... This may take a while"); + Console::WriteLine("Need to collect enough entropy from the system"); key.Generate(); - log_info("Key generated, saving private bits as %s", keyPath); + Console::WriteLine("Key generated, saving private bits as %s", keyPath); SDL_RWops *privkey = SDL_RWFromFile(keyPath, "wb+"); key.SavePrivate(privkey); SDL_RWclose(privkey); @@ -728,7 +731,7 @@ bool Network::BeginClient(const char* host, unsigned short port) safe_strcat(keyPath, "-", MAX_PATH); safe_strcat(keyPath, key.PublicKeyHash().c_str(), MAX_PATH); safe_strcat(keyPath, ".pubkey", MAX_PATH); - log_info("Key generated, saving public bits as %s", keyPath); + Console::WriteLine("Key generated, saving public bits as %s", keyPath); SDL_RWops *pubkey = SDL_RWFromFile(keyPath, "wb+"); key.SavePublic(pubkey); SDL_RWclose(pubkey);