refactor(Core/Logging): switch to fmt style for LOG_ (#10366)

* feat(Core/Common): add support fmt style for ASSERT and ABORT

* correct CheckCompactArrayMaskOverflow

* 1

* Update src/server/game/Spells/Spell.cpp

* rework logging

* add fmt replace logs

* logging

* FMT_LOG_

* settings

* fix startup

* 1

* 2

* 3

* 4

* 5

* fmt::print

* to fmt
This commit is contained in:
Kargatum
2022-01-27 22:44:41 +07:00
committed by GitHub
parent 5228d29379
commit 5969df4e30
211 changed files with 3689 additions and 3842 deletions

View File

@@ -20,7 +20,6 @@
#include "Errors.h"
#include "Log.h"
#include "MapDefines.h"
#include "StringFormat.h"
namespace MMAP
{
@@ -91,7 +90,7 @@ namespace MMAP
FILE* file = fopen(fileName.c_str(), "rb");
if (!file)
{
LOG_DEBUG("maps", "MMAP:loadMapData: Error: Could not open mmap file '%s'", fileName.c_str());
LOG_DEBUG("maps", "MMAP:loadMapData: Error: Could not open mmap file '{}'", fileName);
return false;
}
@@ -100,7 +99,7 @@ namespace MMAP
fclose(file);
if (count != 1)
{
LOG_DEBUG("maps", "MMAP:loadMapData: Error: Could not read params from file '%s'", fileName.c_str());
LOG_DEBUG("maps", "MMAP:loadMapData: Error: Could not read params from file '{}'", fileName);
return false;
}
@@ -109,11 +108,11 @@ namespace MMAP
if (DT_SUCCESS != mesh->init(&params))
{
dtFreeNavMesh(mesh);
LOG_ERROR("maps", "MMAP:loadMapData: Failed to initialize dtNavMesh for mmap %03u from file %s", mapId, fileName.c_str());
LOG_ERROR("maps", "MMAP:loadMapData: Failed to initialize dtNavMesh for mmap {:03} from file {}", mapId, fileName);
return false;
}
LOG_DEBUG("maps", "MMAP:loadMapData: Loaded %03i.mmap", mapId);
LOG_DEBUG("maps", "MMAP:loadMapData: Loaded {:03}.mmap", mapId);
// store inside our map list
MMapData* mmap_data = new MMapData(mesh);
@@ -142,7 +141,7 @@ namespace MMAP
uint32 packedGridPos = packTileID(x, y);
if (mmap->loadedTileRefs.find(packedGridPos) != mmap->loadedTileRefs.end())
{
LOG_ERROR("maps", "MMAP:loadMap: Asked to load already loaded navmesh tile. %03u%02i%02i.mmtile", mapId, x, y);
LOG_ERROR("maps", "MMAP:loadMap: Asked to load already loaded navmesh tile. {:03}{:02}{:02}.mmtile", mapId, x, y);
return false;
}
@@ -151,7 +150,7 @@ namespace MMAP
FILE* file = fopen(fileName.c_str(), "rb");
if (!file)
{
LOG_DEBUG("maps", "MMAP:loadMap: Could not open mmtile file '%s'", fileName.c_str());
LOG_DEBUG("maps", "MMAP:loadMap: Could not open mmtile file '{}'", fileName);
return false;
}
@@ -159,14 +158,14 @@ namespace MMAP
MmapTileHeader fileHeader;
if (fread(&fileHeader, sizeof(MmapTileHeader), 1, file) != 1 || fileHeader.mmapMagic != MMAP_MAGIC)
{
LOG_ERROR("maps", "MMAP:loadMap: Bad header in mmap %03u%02i%02i.mmtile", mapId, x, y);
LOG_ERROR("maps", "MMAP:loadMap: Bad header in mmap {:03}{:02}{:02}.mmtile", mapId, x, y);
fclose(file);
return false;
}
if (fileHeader.mmapVersion != MMAP_VERSION)
{
LOG_ERROR("maps", "MMAP:loadMap: %03u%02i%02i.mmtile was built with generator v%i, expected v%i",
LOG_ERROR("maps", "MMAP:loadMap: {:03}{:02}{:02}.mmtile was built with generator v{}, expected v{}",
mapId, x, y, fileHeader.mmapVersion, MMAP_VERSION);
fclose(file);
return false;
@@ -178,7 +177,7 @@ namespace MMAP
size_t result = fread(data, fileHeader.size, 1, file);
if (!result)
{
LOG_ERROR("maps", "MMAP:loadMap: Bad header or data in mmap %03u%02i%02i.mmtile", mapId, x, y);
LOG_ERROR("maps", "MMAP:loadMap: Bad header or data in mmap {:03}{:02}{:02}.mmtile", mapId, x, y);
fclose(file);
return false;
}
@@ -193,11 +192,11 @@ namespace MMAP
mmap->loadedTileRefs.insert(std::pair<uint32, dtTileRef>(packedGridPos, tileRef));
++loadedTiles;
dtMeshHeader* header = (dtMeshHeader*)data;
LOG_DEBUG("maps", "MMAP:loadMap: Loaded mmtile %03i[%02i,%02i] into %03i[%02i,%02i]", mapId, x, y, mapId, header->x, header->y);
LOG_DEBUG("maps", "MMAP:loadMap: Loaded mmtile {:03}[{:02},{:02}] into {:03}[{:02},{:02}]", mapId, x, y, mapId, header->x, header->y);
return true;
}
LOG_ERROR("maps", "MMAP:loadMap: Could not load %03u%02i%02i.mmtile into navmesh", mapId, x, y);
LOG_ERROR("maps", "MMAP:loadMap: Could not load {:03}{:02}{:02}.mmtile into navmesh", mapId, x, y);
dtFree(data);
return false;
}
@@ -209,7 +208,7 @@ namespace MMAP
if (itr == loadedMMaps.end())
{
// file may not exist, therefore not loaded
LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh map. %03u%02i%02i.mmtile", mapId, x, y);
LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh map. {:03}{:02}{:02}.mmtile", mapId, x, y);
return false;
}
@@ -220,7 +219,7 @@ namespace MMAP
if (mmap->loadedTileRefs.find(packedGridPos) == mmap->loadedTileRefs.end())
{
// file may not exist, therefore not loaded
LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh tile. %03u%02i%02i.mmtile", mapId, x, y);
LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh tile. {:03}{:02}{:02}.mmtile", mapId, x, y);
return false;
}
@@ -232,13 +231,13 @@ namespace MMAP
// this is technically a memory leak
// if the grid is later reloaded, dtNavMesh::addTile will return error but no extra memory is used
// we cannot recover from this error - assert out
LOG_ERROR("maps", "MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y);
LOG_ERROR("maps", "MMAP:unloadMap: Could not unload {:03}{:02}{:02}.mmtile from navmesh", mapId, x, y);
ABORT();
}
mmap->loadedTileRefs.erase(packedGridPos);
--loadedTiles;
LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile %03i[%02i,%02i] from %03i", mapId, x, y, mapId);
LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile {:03}[{:02},{:02}] from {:03}", mapId, x, y, mapId);
return true;
}
@@ -248,7 +247,7 @@ namespace MMAP
if (itr == loadedMMaps.end() || !itr->second)
{
// file may not exist, therefore not loaded
LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh map %03u", mapId);
LOG_DEBUG("maps", "MMAP:unloadMap: Asked to unload not loaded navmesh map {:03}", mapId);
return false;
}
@@ -261,18 +260,18 @@ namespace MMAP
if (dtStatusFailed(mmap->navMesh->removeTile(i.second, nullptr, nullptr)))
{
LOG_ERROR("maps", "MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y);
LOG_ERROR("maps", "MMAP:unloadMap: Could not unload {:03}{:02}{:02}.mmtile from navmesh", mapId, x, y);
}
else
{
--loadedTiles;
LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile %03i[%02i,%02i] from %03i", mapId, x, y, mapId);
LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile {:03}[{:02},{:02}] from {:03}", mapId, x, y, mapId);
}
}
delete mmap;
itr->second = nullptr;
LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded %03i.mmap", mapId);
LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded {:03}.mmap", mapId);
return true;
}
@@ -284,14 +283,14 @@ namespace MMAP
if (itr == loadedMMaps.end())
{
// file may not exist, therefore not loaded
LOG_DEBUG("maps", "MMAP:unloadMapInstance: Asked to unload not loaded navmesh map %03u", mapId);
LOG_DEBUG("maps", "MMAP:unloadMapInstance: Asked to unload not loaded navmesh map {:03}", mapId);
return false;
}
MMapData* mmap = itr->second;
if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end())
{
LOG_DEBUG("maps", "MMAP:unloadMapInstance: Asked to unload not loaded dtNavMeshQuery mapId %03u instanceId %u", mapId, instanceId);
LOG_DEBUG("maps", "MMAP:unloadMapInstance: Asked to unload not loaded dtNavMeshQuery mapId {:03} instanceId {}", mapId, instanceId);
return false;
}
@@ -299,7 +298,7 @@ namespace MMAP
dtFreeNavMeshQuery(query);
mmap->navMeshQueries.erase(instanceId);
LOG_DEBUG("maps", "MMAP:unloadMapInstance: Unloaded mapId %03u instanceId %u", mapId, instanceId);
LOG_DEBUG("maps", "MMAP:unloadMapInstance: Unloaded mapId {:03} instanceId {}", mapId, instanceId);
return true;
}
@@ -336,11 +335,11 @@ namespace MMAP
if (dtStatusFailed(query->init(mmap->navMesh, 1024)))
{
dtFreeNavMeshQuery(query);
LOG_ERROR("maps", "MMAP:GetNavMeshQuery: Failed to initialize dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId);
LOG_ERROR("maps", "MMAP:GetNavMeshQuery: Failed to initialize dtNavMeshQuery for mapId {:03} instanceId {}", mapId, instanceId);
return nullptr;
}
LOG_DEBUG("maps", "MMAP:GetNavMeshQuery: created dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId);
LOG_DEBUG("maps", "MMAP:GetNavMeshQuery: created dtNavMeshQuery for mapId {:03} instanceId {}", mapId, instanceId);
mmap->navMeshQueries.insert(std::pair<uint32, dtNavMeshQuery*>(instanceId, query));
}
}

View File

@@ -348,11 +348,11 @@ namespace VMAP
WorldModel* worldmodel = new WorldModel();
if (!worldmodel->readFile(basepath + filename + ".vmo"))
{
LOG_ERROR("maps", "VMapMgr2: could not load '%s%s.vmo'", basepath.c_str(), filename.c_str());
LOG_ERROR("maps", "VMapMgr2: could not load '{}{}.vmo'", basepath, filename);
delete worldmodel;
return nullptr;
}
LOG_DEBUG("maps", "VMapMgr2: loading file '%s%s'", basepath.c_str(), filename.c_str());
LOG_DEBUG("maps", "VMapMgr2: loading file '{}{}'", basepath, filename);
model = iLoadedModelFiles.insert(std::pair<std::string, ManagedModel>(filename, ManagedModel())).first;
model->second.setModel(worldmodel);
}
@@ -368,12 +368,12 @@ namespace VMAP
ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
if (model == iLoadedModelFiles.end())
{
LOG_ERROR("maps", "VMapMgr2: trying to unload non-loaded file '%s'", filename.c_str());
LOG_ERROR("maps", "VMapMgr2: trying to unload non-loaded file '{}'", filename);
return;
}
if (model->second.decRefCount() == 0)
{
LOG_DEBUG("maps", "VMapMgr2: unloading file '%s'", filename.c_str());
LOG_DEBUG("maps", "VMapMgr2: unloading file '{}'", filename);
delete model->second.getModel();
iLoadedModelFiles.erase(model);
}

View File

@@ -57,7 +57,7 @@ namespace VMAP
void operator()(const Vector3& point, uint32 entry)
{
#if defined(VMAP_DEBUG)
LOG_DEBUG("maps", "AreaInfoCallback: trying to intersect '%s'", prims[entry].name.c_str());
LOG_DEBUG("maps", "AreaInfoCallback: trying to intersect '{}'", prims[entry].name);
#endif
prims[entry].intersectPoint(point, aInfo);
}
@@ -73,7 +73,7 @@ namespace VMAP
void operator()(const Vector3& point, uint32 entry)
{
#if defined(VMAP_DEBUG)
LOG_DEBUG("maps", "LocationInfoCallback: trying to intersect '%s'", prims[entry].name.c_str());
LOG_DEBUG("maps", "LocationInfoCallback: trying to intersect '{}'", prims[entry].name);
#endif
if (prims[entry].GetLocationInfo(point, locInfo))
{
@@ -296,7 +296,7 @@ namespace VMAP
bool StaticMapTree::InitMap(const std::string& fname, VMapMgr2* vm)
{
//VMAP_DEBUG_LOG(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : initializing StaticMapTree '%s'", fname.c_str());
//VMAP_DEBUG_LOG(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : initializing StaticMapTree '{}'", fname);
bool success = false;
std::string fullname = iBasePath + fname;
FILE* rf = fopen(fullname.c_str(), "rb");
@@ -322,12 +322,12 @@ namespace VMAP
// only non-tiled maps have them, and if so exactly one (so far at least...)
ModelSpawn spawn;
#ifdef VMAP_DEBUG
//LOG_DEBUG(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : map isTiled: %u", static_cast<uint32>(iIsTiled));
//LOG_DEBUG(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : map isTiled: {}", static_cast<uint32>(iIsTiled));
#endif
if (!iIsTiled && ModelSpawn::readFromFile(rf, spawn))
{
WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name);
//VMAP_DEBUG_LOG(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : loading %s", spawn.name.c_str());
//VMAP_DEBUG_LOG(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : loading {}", spawn.name);
if (model)
{
// assume that global model always is the first and only tree value (could be improved...)
@@ -337,7 +337,7 @@ namespace VMAP
else
{
success = false;
//VMAP_ERROR_LOG(LOG_FILTER_GENERAL, "StaticMapTree::InitMap() : could not acquire WorldModel pointer for '%s'", spawn.name.c_str());
//VMAP_ERROR_LOG(LOG_FILTER_GENERAL, "StaticMapTree::InitMap() : could not acquire WorldModel pointer for '{}'", spawn.name);
}
}
@@ -374,7 +374,7 @@ namespace VMAP
}
if (!iTreeValues)
{
LOG_ERROR("maps", "StaticMapTree::LoadMapTile() : tree has not been initialized [%u, %u]", tileX, tileY);
LOG_ERROR("maps", "StaticMapTree::LoadMapTile() : tree has not been initialized [{}, {}]", tileX, tileY);
return false;
}
bool result = true;
@@ -405,7 +405,7 @@ namespace VMAP
WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name);
if (!model)
{
LOG_ERROR("maps", "StaticMapTree::LoadMapTile() : could not acquire WorldModel pointer [%u, %u]", tileX, tileY);
LOG_ERROR("maps", "StaticMapTree::LoadMapTile() : could not acquire WorldModel pointer [{}, {}]", tileX, tileY);
}
// update tree
@@ -418,7 +418,7 @@ namespace VMAP
#if defined(VMAP_DEBUG)
if (referencedVal > iNTreeValues)
{
LOG_DEBUG("maps", "StaticMapTree::LoadMapTile() : invalid tree element (%u/%u)", referencedVal, iNTreeValues);
LOG_DEBUG("maps", "StaticMapTree::LoadMapTile() : invalid tree element ({}/{})", referencedVal, iNTreeValues);
continue;
}
#endif
@@ -435,7 +435,7 @@ namespace VMAP
}
else if (iTreeValues[referencedVal].name != spawn.name)
{
LOG_DEBUG("maps", "StaticMapTree::LoadMapTile() : name collision on GUID=%u", spawn.ID);
LOG_DEBUG("maps", "StaticMapTree::LoadMapTile() : name collision on GUID={}", spawn.ID);
}
#endif
}
@@ -468,7 +468,7 @@ namespace VMAP
loadedTileMap::iterator tile = iLoadedTiles.find(tileID);
if (tile == iLoadedTiles.end())
{
LOG_ERROR("maps", "StaticMapTree::UnloadMapTile() : trying to unload non-loaded tile - Map:%u X:%u Y:%u", iMapID, tileX, tileY);
LOG_ERROR("maps", "StaticMapTree::UnloadMapTile() : trying to unload non-loaded tile - Map:{} X:{} Y:{}", iMapID, tileX, tileY);
return;
}
if (tile->second) // file associated with tile
@@ -509,7 +509,7 @@ namespace VMAP
{
if (!iLoadedSpawns.count(referencedNode))
{
LOG_ERROR("maps", "StaticMapTree::UnloadMapTile() : trying to unload non-referenced model '%s' (ID:%u)", spawn.name.c_str(), spawn.ID);
LOG_ERROR("maps", "StaticMapTree::UnloadMapTile() : trying to unload non-referenced model '{}' (ID:{})", spawn.name, spawn.ID);
}
else if (--iLoadedSpawns[referencedNode] == 0)
{

View File

@@ -48,14 +48,14 @@ void LoadGameObjectModelList(std::string const& dataPath)
FILE* model_list_file = fopen((dataPath + "vmaps/" + VMAP::GAMEOBJECT_MODELS).c_str(), "rb");
if (!model_list_file)
{
LOG_ERROR("maps", "Unable to open '%s' file.", VMAP::GAMEOBJECT_MODELS);
LOG_ERROR("maps", "Unable to open '{}' file.", VMAP::GAMEOBJECT_MODELS);
return;
}
char magic[8];
if (fread(magic, 1, 8, model_list_file) != 8 || memcmp(magic, VMAP::VMAP_MAGIC, 8) != 0)
{
LOG_ERROR("maps", "File '%s' has wrong header, expected %s.", VMAP::GAMEOBJECT_MODELS, VMAP::VMAP_MAGIC);
LOG_ERROR("maps", "File '{}' has wrong header, expected {}.", VMAP::GAMEOBJECT_MODELS, VMAP::VMAP_MAGIC);
return;
}
@@ -78,15 +78,15 @@ void LoadGameObjectModelList(std::string const& dataPath)
|| fread(&v1, sizeof(Vector3), 1, model_list_file) != 1
|| fread(&v2, sizeof(Vector3), 1, model_list_file) != 1)
{
LOG_ERROR("maps", "File '%s' seems to be corrupted!", VMAP::GAMEOBJECT_MODELS);
LOG_ERROR("maps", "File '{}' seems to be corrupted!", VMAP::GAMEOBJECT_MODELS);
fclose(model_list_file);
break;
}
if (v1.isNaN() || v2.isNaN())
{
LOG_ERROR("maps", "File '%s' Model '%s' has invalid v1%s v2%s values!",
VMAP::GAMEOBJECT_MODELS, std::string(buff, name_length).c_str(), v1.toString().c_str(), v2.toString().c_str());
LOG_ERROR("maps", "File '{}' Model '{}' has invalid v1{} v2{} values!",
VMAP::GAMEOBJECT_MODELS, std::string(buff, name_length), v1.toString(), v2.toString());
continue;
}
@@ -95,7 +95,7 @@ void LoadGameObjectModelList(std::string const& dataPath)
fclose(model_list_file);
LOG_INFO("server.loading", ">> Loaded %u GameObject models in %u ms", uint32(model_list.size()), GetMSTimeDiffToNow(oldMSTime));
LOG_INFO("server.loading", ">> Loaded {} GameObject models in {} ms", uint32(model_list.size()), GetMSTimeDiffToNow(oldMSTime));
LOG_INFO("server.loading", " ");
}
@@ -119,7 +119,7 @@ bool GameObjectModel::initialize(std::unique_ptr<GameObjectModelOwnerBase> model
// ignore models with no bounds
if (mdl_box == G3D::AABox::zero())
{
LOG_ERROR("maps", "GameObject model %s has zero bounds, loading skipped", it->second.name.c_str());
LOG_ERROR("maps", "GameObject model {} has zero bounds, loading skipped", it->second.name);
return false;
}

View File

@@ -63,7 +63,7 @@ namespace
}
else
{
FMT_LOG_ERROR("server.loading", message);
LOG_ERROR("server.loading", message);
}
}
@@ -255,7 +255,7 @@ T ConfigMgr::GetValueDefault(std::string const& name, T const& def, bool showLog
{
if (showLogs)
{
FMT_LOG_ERROR("server.loading", "> Config: Missing property {} in all config files, at least the .dist file must contain: \"{} = {}\"",
LOG_ERROR("server.loading", "> Config: Missing property {} in all config files, at least the .dist file must contain: \"{} = {}\"",
name, name, Acore::ToString(def));
}
@@ -267,7 +267,7 @@ T ConfigMgr::GetValueDefault(std::string const& name, T const& def, bool showLog
{
if (showLogs)
{
FMT_LOG_ERROR("server.loading", "> Config: Bad value defined for name '{}', going to use '{}' instead",
LOG_ERROR("server.loading", "> Config: Bad value defined for name '{}', going to use '{}' instead",
name, Acore::ToString(def));
}
@@ -285,7 +285,7 @@ std::string ConfigMgr::GetValueDefault<std::string>(std::string const& name, std
{
if (showLogs)
{
FMT_LOG_ERROR("server.loading", "> Config: Missing option {}, add \"{} = {}\"",
LOG_ERROR("server.loading", "> Config: Missing option {}, add \"{} = {}\"",
name, name, def);
}
@@ -311,7 +311,7 @@ bool ConfigMgr::GetOption<bool>(std::string const& name, bool const& def, bool s
{
if (showLogs)
{
FMT_LOG_ERROR("server.loading", "> Config: Bad value defined for name '{}', going to use '{}' instead",
LOG_ERROR("server.loading", "> Config: Bad value defined for name '{}', going to use '{}' instead",
name, def ? "true" : "false");
}
@@ -402,8 +402,8 @@ bool ConfigMgr::LoadModulesConfigs(bool isReload /*= false*/, bool isNeedPrintIn
if (isNeedPrintInfo)
{
FMT_LOG_INFO("server.loading", " ");
FMT_LOG_INFO("server.loading", "Loading modules configuration...");
LOG_INFO("server.loading", " ");
LOG_INFO("server.loading", "Loading modules configuration...");
}
// Start loading module configs
@@ -425,7 +425,7 @@ bool ConfigMgr::LoadModulesConfigs(bool isReload /*= false*/, bool isNeedPrintIn
if (!isReload && !isExistDistConfig)
{
FMT_LOG_FATAL("server.loading", "> ConfigMgr::LoadModulesConfigs: Not found original config '{}'. Stop loading", distFileName);
LOG_FATAL("server.loading", "> ConfigMgr::LoadModulesConfigs: Not found original config '{}'. Stop loading", distFileName);
ABORT();
}
@@ -447,23 +447,23 @@ bool ConfigMgr::LoadModulesConfigs(bool isReload /*= false*/, bool isNeedPrintIn
if (!_moduleConfigFiles.empty())
{
// Print modules configurations
FMT_LOG_INFO("server.loading", " ");
FMT_LOG_INFO("server.loading", "Using modules configuration:");
LOG_INFO("server.loading", " ");
LOG_INFO("server.loading", "Using modules configuration:");
for (auto const& itr : _moduleConfigFiles)
{
FMT_LOG_INFO("server.loading", "> {}", itr);
LOG_INFO("server.loading", "> {}", itr);
}
}
else
{
FMT_LOG_INFO("server.loading", "> Not found modules config files");
LOG_INFO("server.loading", "> Not found modules config files");
}
}
if (isNeedPrintInfo)
{
FMT_LOG_INFO("server.loading", " ");
LOG_INFO("server.loading", " ");
}
return true;

View File

@@ -95,15 +95,9 @@
# define AC_GAME_API AC_API_IMPORT
#endif
#define UI64FMTD "%" PRIu64
#define UI64LIT(N) UINT64_C(N)
#define SI64FMTD "%" PRId64
#define SI64LIT(N) INT64_C(N)
#define SZFMTD "%" PRIuPTR
#define STRING_VIEW_FMT "%.*s"
#define STRING_VIEW_FMT_ARG(str) static_cast<int>((str).length()), (str).data()
typedef std::int64_t int64;

View File

@@ -46,13 +46,13 @@ void IpLocationStore::Load()
std::ifstream databaseFile(databaseFilePath);
if (!databaseFile)
{
LOG_ERROR("server.loading", "IPLocation: No ip database file exists (%s).", databaseFilePath.c_str());
LOG_ERROR("server.loading", "IPLocation: No ip database file exists ({}).", databaseFilePath);
return;
}
if (!databaseFile.is_open())
{
LOG_ERROR("server.loading", "IPLocation: Ip database file (%s) can not be opened.", databaseFilePath.c_str());
LOG_ERROR("server.loading", "IPLocation: Ip database file ({}) can not be opened.", databaseFilePath);
return;
}
@@ -101,7 +101,7 @@ void IpLocationStore::Load()
databaseFile.close();
LOG_INFO("server.loading", ">> Loaded %u ip location entries.", static_cast<uint32>(_ipLocationStore.size()));
LOG_INFO("server.loading", ">> Loaded {} ip location entries.", static_cast<uint32>(_ipLocationStore.size()));
LOG_INFO("server.loading", " ");
}

View File

@@ -52,8 +52,8 @@ void AppenderConsole::InitColors(std::string const& name, std::string_view str)
std::vector<std::string_view> colorStrs = Acore::Tokenize(str, ' ', false);
if (colorStrs.size() != NUM_ENABLED_LOG_LEVELS)
{
throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Invalid color data '%s' for console appender %s (expected %u entries, got %zu)",
std::string(str).c_str(), name.c_str(), NUM_ENABLED_LOG_LEVELS, colorStrs.size()));
throw InvalidAppenderArgsException(Acore::StringFormatFmt("Log::CreateAppenderFromConfig: Invalid color data '{}' for console appender {} (expected {} entries, got {})",
str, name, NUM_ENABLED_LOG_LEVELS, colorStrs.size()));
}
for (uint8 i = 0; i < NUM_ENABLED_LOG_LEVELS; ++i)
@@ -64,8 +64,8 @@ void AppenderConsole::InitColors(std::string const& name, std::string_view str)
}
else
{
throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Invalid color '%s' for log level %s on console appender %s",
std::string(colorStrs[i]).c_str(), EnumUtils::ToTitle(static_cast<LogLevel>(i)), name.c_str()));
throw InvalidAppenderArgsException(Acore::StringFormatFmt("Log::CreateAppenderFromConfig: Invalid color '{}' for log level {} on console appender {}",
colorStrs[i], EnumUtils::ToTitle(static_cast<LogLevel>(i)), name));
}
}

View File

@@ -31,7 +31,7 @@ AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, Ap
{
if (args.size() < 4)
{
throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Missing file name for appender %s", name.c_str()));
throw InvalidAppenderArgsException(Acore::StringFormatFmt("Log::CreateAppenderFromConfig: Missing file name for appender {}", name));
}
_fileName.assign(args[3]);
@@ -63,7 +63,7 @@ AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, Ap
}
else
{
throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Invalid size '%s' for appender %s", std::string(args[5]).c_str(), name.c_str()));
throw InvalidAppenderArgsException(Acore::StringFormatFmt("Log::CreateAppenderFromConfig: Invalid size '{}' for appender {}", args[5], name));
}
}

View File

@@ -76,7 +76,7 @@ void Log::CreateAppenderFromConfig(std::string const& appenderName)
if (size < 2)
{
fprintf(stderr, "Log::CreateAppenderFromConfig: Wrong configuration for appender %s. Config line: %s\n", name.c_str(), options.c_str());
fmt::print(stderr, "Log::CreateAppenderFromConfig: Wrong configuration for appender {}. Config line: {}\n", name, options);
return;
}
@@ -87,13 +87,13 @@ void Log::CreateAppenderFromConfig(std::string const& appenderName)
auto factoryFunction = appenderFactory.find(type);
if (factoryFunction == appenderFactory.end())
{
fprintf(stderr, "Log::CreateAppenderFromConfig: Unknown type '%s' for appender %s\n", std::string(tokens[0]).c_str(), name.c_str());
fmt::print(stderr, "Log::CreateAppenderFromConfig: Unknown type '{}' for appender {}\n", tokens[0], name);
return;
}
if (level > NUM_ENABLED_LOG_LEVELS)
{
fprintf(stderr, "Log::CreateAppenderFromConfig: Wrong Log Level '%s' for appender %s\n", std::string(tokens[1]).c_str(), name.c_str());
fmt::print(stderr, "Log::CreateAppenderFromConfig: Wrong Log Level '{}' for appender {}\n", tokens[1], name);
return;
}
@@ -105,7 +105,7 @@ void Log::CreateAppenderFromConfig(std::string const& appenderName)
}
else
{
fprintf(stderr, "Log::CreateAppenderFromConfig: Unknown flags '%s' for appender %s\n", std::string(tokens[2]).c_str(), name.c_str());
fmt::print(stderr, "Log::CreateAppenderFromConfig: Unknown flags '{}' for appender {}\n", tokens[2], name);
return;
}
}
@@ -117,7 +117,7 @@ void Log::CreateAppenderFromConfig(std::string const& appenderName)
}
catch (InvalidAppenderArgsException const& iaae)
{
fprintf(stderr, "%s\n", iaae.what());
fmt::print(stderr, "{}\n", iaae.what());
}
}
@@ -135,7 +135,7 @@ void Log::CreateLoggerFromConfig(std::string const& appenderName)
if (options.empty())
{
fprintf(stderr, "Log::CreateLoggerFromConfig: Missing config option Logger.%s\n", name.c_str());
fmt::print(stderr, "Log::CreateLoggerFromConfig: Missing config option Logger.{}\n", name);
return;
}
@@ -143,21 +143,21 @@ void Log::CreateLoggerFromConfig(std::string const& appenderName)
if (tokens.size() != 2)
{
fprintf(stderr, "Log::CreateLoggerFromConfig: Wrong config option Logger.%s=%s\n", name.c_str(), options.c_str());
fmt::print(stderr, "Log::CreateLoggerFromConfig: Wrong config option Logger.%s=%s\n", name, options);
return;
}
std::unique_ptr<Logger>& logger = loggers[name];
if (logger)
{
fprintf(stderr, "Error while configuring Logger %s. Already defined\n", name.c_str());
fmt::print(stderr, "Error while configuring Logger {}. Already defined\n", name);
return;
}
level = LogLevel(Acore::StringTo<uint8>(tokens[0]).value_or(LOG_LEVEL_INVALID));
if (level > NUM_ENABLED_LOG_LEVELS)
{
fprintf(stderr, "Log::CreateLoggerFromConfig: Wrong Log Level '%s' for logger %s\n", std::string(tokens[0]).c_str(), name.c_str());
fmt::print(stderr, "Log::CreateLoggerFromConfig: Wrong Log Level '{}' for logger {}\n", tokens[0], name);
return;
}
@@ -167,18 +167,16 @@ void Log::CreateLoggerFromConfig(std::string const& appenderName)
}
logger = std::make_unique<Logger>(name, level);
//fprintf(stdout, "Log::CreateLoggerFromConfig: Created Logger %s, Level %u\n", name.c_str(), level);
for (std::string_view appendName : Acore::Tokenize(tokens[1], ' ', false))
{
if (Appender* appender = GetAppenderByName(appendName))
{
logger->addAppender(appender->getId(), appender);
//fprintf(stdout, "Log::CreateLoggerFromConfig: Added Appender %s to Logger %s\n", appender->getName().c_str(), name.c_str());
}
else
{
fprintf(stderr, "Error while configuring Appender %s in Logger %s. Appender does not exist\n", std::string(appendName).c_str(), name.c_str());
fmt::print(stderr, "Error while configuring Appender {} in Logger {}. Appender does not exist\n", appendName, name);
}
}
}
@@ -203,7 +201,7 @@ void Log::ReadLoggersFromConfig()
// Bad config configuration, creating default config
if (loggers.find(LOGGER_ROOT) == loggers.end())
{
fprintf(stderr, "Wrong Loggers configuration. Review your Logger config section.\n"
fmt::print(stderr, "Wrong Loggers configuration. Review your Logger config section.\n"
"Creating default loggers [root (Error), server (Info)] to console\n");
Close(); // Clean any Logger or Appender created
@@ -228,19 +226,14 @@ void Log::RegisterAppender(uint8 index, AppenderCreatorFn appenderCreateFn)
appenderFactory[index] = appenderCreateFn;
}
void Log::outMessage(std::string const& filter, LogLevel level, std::string&& message)
void Log::_outMessage(std::string const& filter, LogLevel level, std::string_view message)
{
write(std::make_unique<LogMessage>(level, filter, std::move(message)));
write(std::make_unique<LogMessage>(level, filter, message));
}
void Log::_outMessageFmt(std::string const& filter, LogLevel level, std::string&& message)
void Log::_outCommand(std::string_view message, std::string_view param1)
{
write(std::make_unique<LogMessage>(level, filter, std::move(message)));
}
void Log::outCommand(std::string&& message, std::string&& param1)
{
write(std::make_unique<LogMessage>(LOG_LEVEL_INFO, "commands.gm", std::move(message), std::move(param1)));
write(std::make_unique<LogMessage>(LOG_LEVEL_INFO, "commands.gm", message, param1));
}
void Log::write(std::unique_ptr<LogMessage>&& msg) const
@@ -321,22 +314,17 @@ bool Log::SetLogLevel(std::string const& name, int32 newLeveli, bool isLogger /*
return true;
}
void Log::outCharDump(char const* str, uint32 accountId, uint64 guid, char const* name)
void Log::outCharDump(std::string_view str, uint32 accountId, uint64 guid, std::string_view name)
{
if (!str || !ShouldLog("entities.player.dump", LOG_LEVEL_INFO))
if (str.empty() || !ShouldLog("entities.player.dump", LOG_LEVEL_INFO))
{
return;
}
std::ostringstream ss;
ss << "== START DUMP == (account: " << accountId << " guid: " << guid << " name: " << name
<< ")\n" << str << "\n== END DUMP ==\n";
std::string message = Acore::StringFormatFmt("== START DUMP == (account: {} guid: {} name: {})\n {} \n== END DUMP ==\n", accountId, guid, name, str);
std::unique_ptr<LogMessage> msg(new LogMessage(LOG_LEVEL_INFO, "entities.player.dump", ss.str()));
std::ostringstream param;
param << guid << '_' << name;
msg->param1 = param.str();
std::unique_ptr<LogMessage> msg(new LogMessage(LOG_LEVEL_INFO, "entities.player.dump", message));
msg->param1 = Acore::StringFormatFmt("{}_{}", guid, name);
write(std::move(msg));
}

View File

@@ -60,30 +60,24 @@ public:
[[nodiscard]] bool ShouldLog(std::string const& type, LogLevel level) const;
bool SetLogLevel(std::string const& name, int32 level, bool isLogger = true);
template<typename Format, typename... Args>
inline void outMessage(std::string const& filter, LogLevel const level, Format&& fmt, Args&&... args)
template<typename... Args>
inline void outMessage(std::string const& filter, LogLevel const level, std::string_view fmt, Args&&... args)
{
outMessage(filter, level, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
_outMessage(filter, level, Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
}
template<typename... Args>
inline void outMessageFmt(std::string const& filter, LogLevel const level, std::string_view fmt, Args&&... args)
{
_outMessageFmt(filter, level, fmt::format(fmt, std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
void outCommand(uint32 account, Format&& fmt, Args&&... args)
void outCommand(uint32 account, std::string_view fmt, Args&&... args)
{
if (!ShouldLog("commands.gm", LOG_LEVEL_INFO))
{
return;
}
outCommand(Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...), std::to_string(account));
_outCommand(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...), std::to_string(account));
}
void outCharDump(char const* str, uint32 account_id, uint64 guid, char const* name);
void outCharDump(std::string_view str, uint32 account_id, uint64 guid, std::string_view name);
void SetRealmId(uint32 id);
@@ -96,91 +90,6 @@ public:
[[nodiscard]] std::string const& GetLogsDir() const { return m_logsDir; }
[[nodiscard]] std::string const& GetLogsTimestamp() const { return m_logsTimestamp; }
// Deprecated functions
template<typename Format, typename... Args>
inline void outString(Format&& fmt, Args&& ... args)
{
outMessage("server", LOG_LEVEL_INFO, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
inline void outString()
{
outMessage("server", LOG_LEVEL_INFO, " ");
}
template<typename Format, typename... Args>
inline void outError(Format&& fmt, Args&& ... args)
{
outMessage("server", LOG_LEVEL_ERROR, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
void outErrorDb(Format&& fmt, Args&& ... args)
{
if (!ShouldLog("sql.sql", LOG_LEVEL_ERROR))
{
return;
}
outMessage("sql.sql", LOG_LEVEL_ERROR, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
inline void outBasic(Format&& fmt, Args&& ... args)
{
outMessage("server", LOG_LEVEL_INFO, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
inline void outDetail(Format&& fmt, Args&& ... args)
{
outMessage("server", LOG_LEVEL_INFO, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
void outSQLDev(Format&& fmt, Args&& ... args)
{
if (!ShouldLog("sql.dev", LOG_LEVEL_INFO))
{
return;
}
outMessage("sql.dev", LOG_LEVEL_INFO, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
void outSQLDriver(Format&& fmt, Args&& ... args)
{
if (!ShouldLog("sql.driver", LOG_LEVEL_INFO))
{
return;
}
outMessage("sql.driver", LOG_LEVEL_INFO, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
inline void outMisc(Format&& fmt, Args&& ... args)
{
outMessage("server", LOG_LEVEL_INFO, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
void outDebug(DebugLogFilters filter, Format&& fmt, Args&& ... args)
{
if (!(_debugLogMask & filter))
{
return;
}
if (!ShouldLog("server", LOG_LEVEL_DEBUG))
{
return;
}
outMessage("server", LOG_LEVEL_DEBUG, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
private:
static std::string GetTimestampStr();
void write(std::unique_ptr<LogMessage>&& msg) const;
@@ -193,9 +102,8 @@ private:
void ReadAppendersFromConfig();
void ReadLoggersFromConfig();
void RegisterAppender(uint8 index, AppenderCreatorFn appenderCreateFn);
void outMessage(std::string const& filter, LogLevel level, std::string&& message);
void _outMessageFmt(std::string const& filter, LogLevel level, std::string&& message);
void outCommand(std::string&& message, std::string&& param1);
void _outMessage(std::string const& filter, LogLevel level, std::string_view message);
void _outCommand(std::string_view message, std::string_view param1);
std::unordered_map<uint8, AppenderCreatorFn> appenderFactory;
std::unordered_map<uint8, std::unique_ptr<Appender>> appenders;
@@ -216,41 +124,24 @@ private:
{ \
try \
{ \
sLog->outMessage(filterType__, level__, __VA_ARGS__); \
sLog->outMessage(filterType__, level__, fmt::format(__VA_ARGS__)); \
} \
catch (std::exception const& e) \
{ \
sLog->outMessage("server", LOG_LEVEL_ERROR, "Wrong format occurred (%s) at %s:%u.", \
sLog->outMessage("server", LogLevel::LOG_LEVEL_ERROR, "Wrong format occurred ({}) at '{}:{}'", \
e.what(), __FILE__, __LINE__); \
} \
}
#ifdef PERFORMANCE_PROFILING
#define LOG_MESSAGE_BODY(filterType__, level__, ...) ((void)0)
#elif AC_PLATFORM != AC_PLATFORM_WINDOWS
void check_args(char const*, ...) ATTR_PRINTF(1, 2);
void check_args(std::string const&, ...);
// This will catch format errors on build time
#define LOG_MESSAGE_BODY(filterType__, level__, ...) \
do { \
if (sLog->ShouldLog(filterType__, level__)) \
{ \
if (false) \
check_args(__VA_ARGS__); \
\
LOG_EXCEPTION_FREE(filterType__, level__, __VA_ARGS__); \
} \
} while (0)
#else
#define LOG_MESSAGE_BODY(filterType__, level__, ...) \
__pragma(warning(push)) \
__pragma(warning(disable:4127)) \
do { \
#define LOG_MESSAGE_BODY(filterType__, level__, ...) \
do \
{ \
if (sLog->ShouldLog(filterType__, level__)) \
LOG_EXCEPTION_FREE(filterType__, level__, __VA_ARGS__); \
} while (0) \
__pragma(warning(pop))
} while (0)
#endif
// Fatal - 1
@@ -283,49 +174,4 @@ void check_args(std::string const&, ...);
#define LOG_GM(accountId__, ...) \
sLog->outCommand(accountId__, __VA_ARGS__)
// New format logging
#define FMT_LOG_EXCEPTION_FREE(filterType__, level__, ...) \
{ \
try \
{ \
sLog->outMessageFmt(filterType__, level__, fmt::format(__VA_ARGS__)); \
} \
catch (const std::exception& e) \
{ \
sLog->outMessageFmt("server", LogLevel::LOG_LEVEL_ERROR, "Wrong format occurred ({}) at '{}:{}'", \
e.what(), __FILE__, __LINE__); \
} \
}
#define FMT_LOG_MESSAGE_BODY(filterType__, level__, ...) \
do \
{ \
if (sLog->ShouldLog(filterType__, level__)) \
FMT_LOG_EXCEPTION_FREE(filterType__, level__, __VA_ARGS__); \
} while (0)
// Fatal - 1
#define FMT_LOG_FATAL(filterType__, ...) \
FMT_LOG_MESSAGE_BODY(filterType__, LogLevel::LOG_LEVEL_FATAL, __VA_ARGS__)
// Error - 2
#define FMT_LOG_ERROR(filterType__, ...) \
FMT_LOG_MESSAGE_BODY(filterType__, LogLevel::LOG_LEVEL_ERROR, __VA_ARGS__)
// Warning - 3
#define FMT_LOG_WARN(filterType__, ...) \
FMT_LOG_MESSAGE_BODY(filterType__, LogLevel::LOG_LEVEL_WARN, __VA_ARGS__)
// Info - 4
#define FMT_LOG_INFO(filterType__, ...) \
FMT_LOG_MESSAGE_BODY(filterType__, LogLevel::LOG_LEVEL_INFO, __VA_ARGS__)
// Debug - 5
#define FMT_LOG_DEBUG(filterType__, ...) \
FMT_LOG_MESSAGE_BODY(filterType__, LogLevel::LOG_LEVEL_DEBUG, __VA_ARGS__)
// Trace - 6
#define FMT_LOG_TRACE(filterType__, ...) \
FMT_LOG_MESSAGE_BODY(filterType__, LogLevel::LOG_LEVEL_TRACE, __VA_ARGS__)
#endif // _LOG_H__

View File

@@ -19,15 +19,11 @@
#include "StringFormat.h"
#include "Timer.h"
LogMessage::LogMessage(LogLevel _level, std::string const& _type, std::string&& _text)
: level(_level), type(_type), text(std::forward<std::string>(_text)), mtime(GetEpochTime())
{
}
LogMessage::LogMessage(LogLevel _level, std::string const& _type, std::string_view _text)
: level(_level), type(_type), text(std::string(_text)), mtime(GetEpochTime()) { }
LogMessage::LogMessage(LogLevel _level, std::string const& _type, std::string&& _text, std::string&& _param1)
: level(_level), type(_type), text(std::forward<std::string>(_text)), param1(std::forward<std::string>(_param1)), mtime(GetEpochTime())
{
}
LogMessage::LogMessage(LogLevel _level, std::string const& _type, std::string_view _text, std::string_view _param1)
: level(_level), type(_type), text(std::string(_text)), param1(std::string(_param1)), mtime(GetEpochTime()) { }
std::string LogMessage::getTimeStr(Seconds time)
{

View File

@@ -25,8 +25,8 @@
struct LogMessage
{
LogMessage(LogLevel _level, std::string const& _type, std::string&& _text);
LogMessage(LogLevel _level, std::string const& _type, std::string&& _text, std::string&& _param1);
LogMessage(LogLevel _level, std::string const& _type, std::string_view _text);
LogMessage(LogLevel _level, std::string const& _type, std::string_view _text, std::string_view _param1);
LogMessage(LogMessage const& /*other*/) = delete;
LogMessage& operator=(LogMessage const& /*other*/) = delete;

View File

@@ -56,7 +56,7 @@ bool Metric::Connect()
auto error = stream.error();
if (error)
{
FMT_LOG_ERROR("metric", "Error connecting to '{}:{}', disabling Metric. Error message: {}",
LOG_ERROR("metric", "Error connecting to '{}:{}', disabling Metric. Error message: {}",
_hostname, _port, error.message());
_enabled = false;
@@ -75,14 +75,14 @@ void Metric::LoadFromConfigs()
if (_updateInterval < 1)
{
FMT_LOG_ERROR("metric", "'Metric.Interval' config set to {}, overriding to 1.", _updateInterval);
LOG_ERROR("metric", "'Metric.Interval' config set to {}, overriding to 1.", _updateInterval);
_updateInterval = 1;
}
_overallStatusTimerInterval = sConfigMgr->GetOption<int32>("Metric.OverallStatusInterval", 1);
if (_overallStatusTimerInterval < 1)
{
FMT_LOG_ERROR("metric", "'Metric.OverallStatusInterval' config set to {}, overriding to 1.", _overallStatusTimerInterval);
LOG_ERROR("metric", "'Metric.OverallStatusInterval' config set to {}, overriding to 1.", _overallStatusTimerInterval);
_overallStatusTimerInterval = 1;
}
@@ -102,14 +102,14 @@ void Metric::LoadFromConfigs()
std::string connectionInfo = sConfigMgr->GetOption<std::string>("Metric.ConnectionInfo", "");
if (connectionInfo.empty())
{
FMT_LOG_ERROR("metric", "'Metric.ConnectionInfo' not specified in configuration file.");
LOG_ERROR("metric", "'Metric.ConnectionInfo' not specified in configuration file.");
return;
}
std::vector<std::string_view> tokens = Acore::Tokenize(connectionInfo, ';', true);
if (tokens.size() != 3)
{
FMT_LOG_ERROR("metric", "'Metric.ConnectionInfo' specified with wrong format in configuration file.");
LOG_ERROR("metric", "'Metric.ConnectionInfo' specified with wrong format in configuration file.");
return;
}
@@ -222,7 +222,7 @@ void Metric::SendBatch()
if (status_code != 204)
{
FMT_LOG_ERROR("metric", "Error sending data, returned HTTP code: {}", status_code);
LOG_ERROR("metric", "Error sending data, returned HTTP code: {}", status_code);
}
// Read and ignore the status description

View File

@@ -254,7 +254,7 @@ bool WinServiceRun()
if (!StartServiceCtrlDispatcher(serviceTable))
{
LOG_ERROR("server", "StartService Failed. Error [%u]", ::GetLastError());
LOG_ERROR("server", "StartService Failed. Error [{}]", ::GetLastError());
return false;
}
return true;

View File

@@ -44,15 +44,15 @@ void SetProcessPriority(std::string const& logChannel, uint32 affinity, bool hig
if (!currentAffinity)
{
LOG_ERROR(logChannel, "Processors marked in UseProcessors bitmask (hex) %x are not accessible. Accessible processors bitmask (hex): %x", affinity, appAff);
LOG_ERROR(logChannel, "Processors marked in UseProcessors bitmask (hex) {:x} are not accessible. Accessible processors bitmask (hex): {:x}", affinity, appAff);
}
else if (SetProcessAffinityMask(hProcess, currentAffinity))
{
LOG_INFO(logChannel, "Using processors (bitmask, hex): %x", currentAffinity);
LOG_INFO(logChannel, "Using processors (bitmask, hex): {:x}", currentAffinity);
}
else
{
LOG_ERROR(logChannel, "Can't set used processors (hex): %x", currentAffinity);
LOG_ERROR(logChannel, "Can't set used processors (hex): {:x}", currentAffinity);
}
}
}
@@ -84,13 +84,13 @@ void SetProcessPriority(std::string const& logChannel, uint32 affinity, bool hig
if (sched_setaffinity(0, sizeof(mask), &mask))
{
LOG_ERROR(logChannel, "Can't set used processors (hex): %x, error: %s", affinity, strerror(errno));
LOG_ERROR(logChannel, "Can't set used processors (hex): {:x}, error: {}", affinity, strerror(errno));
}
else
{
CPU_ZERO(&mask);
sched_getaffinity(0, sizeof(mask), &mask);
LOG_INFO(logChannel, "Using processors (bitmask, hex): %lx", *(__cpu_mask*)(&mask));
LOG_INFO(logChannel, "Using processors (bitmask, hex): {:x}", *(__cpu_mask*)(&mask));
}
}
@@ -98,11 +98,11 @@ void SetProcessPriority(std::string const& logChannel, uint32 affinity, bool hig
{
if (setpriority(PRIO_PROCESS, 0, PROCESS_HIGH_PRIORITY))
{
LOG_ERROR(logChannel, "Can't set process priority class, error: %s", strerror(errno));
LOG_ERROR(logChannel, "Can't set process priority class, error: {}", strerror(errno));
}
else
{
LOG_INFO(logChannel, "Process priority class set to %i", getpriority(PRIO_PROCESS, 0));
LOG_INFO(logChannel, "Process priority class set to {}", getpriority(PRIO_PROCESS, 0));
}
}

View File

@@ -77,8 +77,8 @@ namespace Acore
if (!secure)
{
LOG_TRACE(logger, "Starting process \"%s\" with arguments: \"%s\".",
executable.c_str(), boost::algorithm::join(argsVector, " ").c_str());
LOG_TRACE(logger, "Starting process \"{}\" with arguments: \"{}\".",
executable, boost::algorithm::join(argsVector, " "));
}
// prepare file with only read permission (boost process opens with read_write)
@@ -119,12 +119,12 @@ namespace Acore
auto outInfo = MakeACLogSink([&](std::string const& msg)
{
LOG_INFO(logger, "%s", msg.c_str());
LOG_INFO(logger, "{}", msg);
});
auto outError = MakeACLogSink([&](std::string const& msg)
{
LOG_ERROR(logger, "%s", msg.c_str());
LOG_ERROR(logger, "{}", msg);
});
copy(outStream, outInfo);
@@ -136,8 +136,8 @@ namespace Acore
if (!secure)
{
LOG_TRACE(logger, ">> Process \"%s\" finished with return value %i.",
executable.c_str(), result);
LOG_TRACE(logger, ">> Process \"{}\" finished with return value {}.",
executable, result);
}
return result;