108 lines
3.1 KiB
C++
108 lines
3.1 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// (c) Copyright, Ubisoft Entertainment Inc. || Created by Harbour //
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
#include "ubiservices/loggingHelper.h"
|
|
#include "ubiservices/core/configs/configpriv.h"
|
|
#include "ubiservices/core/helpers/instancesManager.h"
|
|
|
|
namespace US_NS {;
|
|
|
|
// Trick to enable this class on Unity wrapper however we don't want any of this functions
|
|
// to do anything on release that's why there is a check inside of each function.
|
|
void LoggingHelper::enableVerbose(bool state)
|
|
{
|
|
#if defined(US_LOG_ENABLED)
|
|
if(InstancesManager::getInstance() != nullptr)
|
|
{
|
|
EventLog& eventLog = InstancesManager::getInstance()->getEventLog();
|
|
|
|
if(state)
|
|
{
|
|
eventLog.setLogLevel(LogLevel::Debug);
|
|
US_LOG(LogLevel::Info, LogCategory::Core, "UbiServices logs are enabled.");
|
|
|
|
disableCategory(LogCategory::Scheduler, DisableScope::NotEnablingOthers);
|
|
disableCategory(LogCategory::Task, DisableScope::NotEnablingOthers);
|
|
disableCategory(LogCategory::Job, DisableScope::NotEnablingOthers);
|
|
disableCategory(LogCategory::HttpEngine, DisableScope::NotEnablingOthers);
|
|
disableCategory(LogCategory::Async, DisableScope::NotEnablingOthers);
|
|
}
|
|
else
|
|
{
|
|
eventLog.setLogLevel(LogLevel::Warning);
|
|
}
|
|
}
|
|
#else
|
|
US_UNUSED(state);
|
|
#endif
|
|
}
|
|
|
|
void LoggingHelper::enableCategory(LogCategory category, EnableScope scope)
|
|
{
|
|
#if defined(US_LOG_ENABLED)
|
|
if(InstancesManager::getInstance() != nullptr)
|
|
{
|
|
EventLog& eventLog = InstancesManager::getInstance()->getEventLog();
|
|
eventLog.enableCategory(category, scope);
|
|
}
|
|
#else
|
|
US_UNUSED(category);
|
|
US_UNUSED(scope);
|
|
#endif
|
|
}
|
|
|
|
void LoggingHelper::disableCategory(LogCategory category, DisableScope scope)
|
|
{
|
|
#if defined(US_LOG_ENABLED)
|
|
if(InstancesManager::getInstance() != nullptr)
|
|
{
|
|
EventLog& eventLog = InstancesManager::getInstance()->getEventLog();
|
|
eventLog.disableCategory(category, scope);
|
|
}
|
|
#else
|
|
US_UNUSED(category);
|
|
US_UNUSED(scope);
|
|
#endif
|
|
}
|
|
|
|
void LoggingHelper::setLevel(LogLevel level)
|
|
{
|
|
#if defined(US_LOG_ENABLED)
|
|
if(InstancesManager::getInstance() != nullptr)
|
|
{
|
|
EventLog& eventLog = InstancesManager::getInstance()->getEventLog();
|
|
eventLog.setLogLevel(level);
|
|
}
|
|
#else
|
|
US_UNUSED(level);
|
|
#endif
|
|
}
|
|
|
|
void LoggingHelper::setCategoryLevel(LogCategory category, LogLevel level)
|
|
{
|
|
#if defined(US_LOG_ENABLED)
|
|
if (InstancesManager::getInstance() != nullptr)
|
|
{
|
|
EventLog& eventLog = InstancesManager::getInstance()->getEventLog();
|
|
eventLog.setCategoryLevel(category, level);
|
|
}
|
|
#else
|
|
US_UNUSED(category);
|
|
US_UNUSED(level);
|
|
#endif
|
|
}
|
|
|
|
void LoggingHelper::enableMultiLines(bool state)
|
|
{
|
|
#if defined(US_LOG_ENABLED)
|
|
if(InstancesManager::getInstance() != nullptr)
|
|
{
|
|
EventLog& eventLog = InstancesManager::getInstance()->getEventLog();
|
|
eventLog.enableMultiLines(state);
|
|
}
|
|
#else
|
|
US_UNUSED(state);
|
|
#endif
|
|
}
|
|
|
|
};
|