refactor(Core/Server): Move Banner into separate file (#5207)

* refactor(Core/Server): Move Banner into separate file

* fix build

* Update Banner.cpp

* indent

* build

* build

* log

* LOG_INFO

* Update Banner.cpp

* Update Banner.h

* Update Main.cpp

* Update Main.cpp

* Update Master.cpp

* yes

* tes
This commit is contained in:
Kitzunu
2021-04-18 00:35:35 +02:00
committed by GitHub
parent 8c8bc61b40
commit 86192f38b7
5 changed files with 75 additions and 40 deletions

31
src/common/Banner.cpp Normal file
View File

@@ -0,0 +1,31 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v3 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
*/
#include "Banner.h"
#include "GitRevision.h"
#include "StringFormat.h"
void acore::Banner::Show(char const* applicationName, void(*log)(char const* text), void(*logExtraInfo)())
{
log(acore::StringFormat("%s (%s)", GitRevision::GetFullVersion(), applicationName).c_str());
log("<Ctrl-C> to stop.\n");
log(" █████╗ ███████╗███████╗██████╗ ██████╗ ████████╗██╗ ██╗");
log(" ██╔══██╗╚══███╔╝██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝██║ ██║");
log(" ███████║ ███╔╝ █████╗ ██████╔╝██║ ██║ ██║ ███████║");
log(" ██╔══██║ ███╔╝ ██╔══╝ ██╔══██╗██║ ██║ ██║ ██╔══██║");
log(" ██║ ██║███████╗███████╗██║ ██║╚██████╔╝ ██║ ██║ ██║");
log(" ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝");
log(" ██████╗ ██████╗ ██████╗ ███████╗");
log(" ██╔════╝██╔═══██╗██╔══██╗██╔═══╝");
log(" ██║ ██║ ██║██████╔╝█████╗");
log(" ██║ ██║ ██║██╔══██╗██╔══╝");
log(" ╚██████╗╚██████╔╝██║ ██║███████╗");
log(" ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝\n");
log(" AzerothCore 3.3.5a - www.azerothcore.org\n");
if (logExtraInfo)
{
logExtraInfo();
}
}

18
src/common/Banner.h Normal file
View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v3 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
*/
#ifndef AZEROTHCORE_BANNER_H
#define AZEROTHCORE_BANNER_H
#include "Define.h"
namespace acore
{
namespace Banner
{
void Show(char const* applicationName, void(*log)(char const* text), void(*logExtraInfo)());
}
}
#endif // AZEROTHCORE_BANNER_H

View File

@@ -12,6 +12,7 @@
* authentication server
*/
#include "Banner.h"
#include "Common.h"
#include "AppenderDB.h"
#include "DatabaseEnv.h"
@@ -85,25 +86,18 @@ extern int main(int argc, char** argv)
sLog->RegisterAppender<AppenderDB>();
sLog->Initialize();
LOG_INFO("server.authserver", "%s (authserver)", GitRevision::GetFullVersion());
LOG_INFO("server.authserver", "<Ctrl-C> to stop.");
LOG_INFO("server.authserver", " ");
LOG_INFO("server.authserver", " █████╗ ███████╗███████╗██████╗ ██████╗ ████████╗██╗ ██╗");
LOG_INFO("server.authserver", " ██╔══██╗╚══███╔╝██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝██║ ██║");
LOG_INFO("server.authserver", " ███████║ ███╔╝ █████╗ ██████╔╝██║ ██║ ██║ ███████║");
LOG_INFO("server.authserver", " ██╔══██║ ███╔╝ ██╔══╝ ██╔══██╗██║ ██║ ██║ ██╔══██║");
LOG_INFO("server.authserver", " ██║ ██║███████╗███████╗██║ ██║╚██████╔╝ ██║ ██║ ██║");
LOG_INFO("server.authserver", " ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝");
LOG_INFO("server.authserver", " ██████╗ ██████╗ ██████╗ ███████╗");
LOG_INFO("server.authserver", " ██╔════╝██╔═══██╗██╔══██╗██╔═══╝");
LOG_INFO("server.authserver", " ██║ ██║ ██║██████╔╝█████╗");
LOG_INFO("server.authserver", " ██║ ██║ ██║██╔══██╗██╔══╝");
LOG_INFO("server.authserver", " ╚██████╗╚██████╔╝██║ ██║███████╗");
LOG_INFO("server.authserver", " ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝\n");
LOG_INFO("server.authserver", " AzerothCore 3.3.5a - www.azerothcore.org");
LOG_INFO("server.authserver", " ");
LOG_INFO("server.authserver", "Using configuration file %s.", configFile.c_str());
LOG_INFO("server.authserver", "%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
acore::Banner::Show("authserver",
[](char const* text)
{
LOG_INFO("server.authserver", "%s", text);
},
[]()
{
LOG_INFO("server.authserver", "> Using configuration file %s.", sConfigMgr->GetFilename().c_str());
LOG_INFO("server.authserver", "> Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
LOG_INFO("server.authserver", "> Using ACE version: %s", ACE_VERSION);
}
);
#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
ACE_Reactor::instance(new ACE_Reactor(new ACE_Dev_Poll_Reactor(ACE::max_handles(), 1), 1), true);

View File

@@ -9,6 +9,7 @@
/// \file
#include "AppenderDB.h"
#include "Banner.h"
#include "Common.h"
#include "Configuration/Config.h"
#include "Database/DatabaseEnv.h"
@@ -122,9 +123,18 @@ extern int main(int argc, char** argv)
sLog->RegisterAppender<AppenderDB>();
sLog->Initialize();
LOG_INFO("server.worldserver", "Using configuration file %s.", configFile.c_str());
LOG_INFO("server.worldserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
LOG_INFO("server.worldserver", "Using ACE version: %s", ACE_VERSION);
acore::Banner::Show("worldserver-daemon",
[](char const* text)
{
LOG_INFO("server.worldserver", "%s", text);
},
[]()
{
LOG_INFO("server.worldserver", "> Using configuration file %s.", sConfigMgr->GetFilename().c_str());
LOG_INFO("server.worldserver", "> Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
LOG_INFO("server.worldserver", "> Using ACE version: %s", ACE_VERSION);
}
);
///- and run the 'Master'
/// @todo Why do we need this 'Master'? Can't all of this be in the Main as for Realmd?

View File

@@ -112,24 +112,6 @@ int Master::Run()
BigNumber seed1;
seed1.SetRand(16 * 8);
LOG_INFO("server", "%s (worldserver-daemon)", GitRevision::GetFullVersion());
LOG_INFO("server", "<Ctrl-C> to stop.\n");
LOG_INFO("server", " █████╗ ███████╗███████╗██████╗ ██████╗ ████████╗██╗ ██╗");
LOG_INFO("server", " ██╔══██╗╚══███╔╝██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝██║ ██║");
LOG_INFO("server", " ███████║ ███╔╝ █████╗ ██████╔╝██║ ██║ ██║ ███████║");
LOG_INFO("server", " ██╔══██║ ███╔╝ ██╔══╝ ██╔══██╗██║ ██║ ██║ ██╔══██║");
LOG_INFO("server", " ██║ ██║███████╗███████╗██║ ██║╚██████╔╝ ██║ ██║ ██║");
LOG_INFO("server", " ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝");
LOG_INFO("server", " ██████╗ ██████╗ ██████╗ ███████╗");
LOG_INFO("server", " ██╔════╝██╔═══██╗██╔══██╗██╔═══╝");
LOG_INFO("server", " ██║ ██║ ██║██████╔╝█████╗");
LOG_INFO("server", " ██║ ██║ ██║██╔══██╗██╔══╝");
LOG_INFO("server", " ╚██████╗╚██████╔╝██║ ██║███████╗");
LOG_INFO("server", " ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝\n");
LOG_INFO("server", " AzerothCore 3.3.5a - www.azerothcore.org\n");
/// worldserver PID file creation
std::string pidFile = sConfigMgr->GetOption<std::string>("PidFile", "");
if (!pidFile.empty())