8 #include "Arp/System/Core/event.hxx" 9 #include "Arp/System/Core/TypeName.hxx" 10 #include "Arp/System/Core/AppDomainSingleton.hxx" 11 #include "Arp/System/Commons/Threading/Mutex.hpp" 12 #include "Arp/System/Commons/Diagnostics/Logging/LogLevel.hpp" 13 #include "Arp/System/Commons/Diagnostics/Logging/LogInfo.hpp" 14 #include "Arp/System/Commons/Diagnostics/Logging/Internal/LogAdapter.hpp" 26 namespace Arp {
namespace System {
namespace Commons {
namespace Diagnostics {
namespace Logging
32 class LogEventAppender;
40 friend class Internal::LogAdapter;
46 using LogAdapter = Internal::LogAdapter;
47 using LogEventAppenderPtr = std::shared_ptr<Internal::LogEventAppender>;
49 using AppendDelegate = delegate<void(const LogInfo&)>;
53 LogManager(
const LogManager&) =
delete;
55 LogManager& operator=(
const LogManager&) =
delete;
58 static void AssignAppDomain(
AppDomain& otherDomain);
59 static void Create(
const char* configFileName);
60 static void Create(
bool enableConsoleLogging,
const char* logFileName =
nullptr);
61 static void Create(LogLevel logLevel,
bool enableConsoleLogging,
const char* logFileName =
nullptr);
62 static void Create(
const char* layoutPattern,
bool enableConsoleLogging,
const char* logFileName =
nullptr);
63 static void Create(LogLevel logLevel,
const char* layoutPattern,
bool enableConsoleLogging,
const char* logFileName =
nullptr);
64 static void Dispose(
void);
67 void SetRootLevel(LogLevel value);
68 LogLevel GetRootLevel(
void);
69 Mutex& GetSyncRoot(
void);
72 LogAdapter CreateLogAdapter(
const char* loggerName);
73 void AddAppendDelegate(AppendDelegate appendDelegate);
74 void RemoveAppendDelegate(AppendDelegate appendDelegate);
77 void Initialize(LogLevel rootLevel, log4cplus::Logger& rootLogger);
78 log4cplus::Logger GetLoggerInstance(
const char* loggerName);
79 bool HasAppendEvent(
void);
80 void FireAppendEvent(
const LogInfo& logInfo);
84 LogAdapter::Ptr rootLogAdapterPtr;
85 log4cplus::Hierarchy* pRootHierarchy;
86 log4cplus::Initializer* pInitializer;
89 static std::atomic<size_t> appendEventCounter;
93 static const char*
const defaultLayoutPattern;
99 inline void LogManager::SetRootLevel(LogLevel value)
101 this->rootLogAdapterPtr->SetLogLevel(value);
104 inline LogLevel LogManager::GetRootLevel()
107 return this->rootLogAdapterPtr->logLevel;
112 return this->syncRoot;
115 inline bool LogManager::HasAppendEvent()
117 return appendEventCounter > 0;
120 inline void LogManager::Create(
bool enableConsoleLogging,
const char* logFileName)
122 Create(LogLevel::Default,
nullptr, enableConsoleLogging, logFileName);
125 inline void LogManager::Create(LogLevel logLevel,
bool enableConsoleLogging,
const char* logFileName)
127 Create(logLevel,
nullptr, enableConsoleLogging, logFileName);
130 inline void LogManager::Create(
const char* layoutPattern,
bool enableConsoleLogging,
const char* logFileName)
132 Create(LogLevel::Default, layoutPattern, enableConsoleLogging, logFileName);
Mutual exclusion object to prevent data from concurrent modifications.
Definition: Mutex.hpp:25
Definition: LogManager.hpp:37
Definition: LogInfo.hpp:19
This class represents a single application domain for each process and is implemented as singleton...
Definition: AppDomain.hpp:122
Use this class to register and invoke several delegates (function pointer in OOP design).
Definition: event.hxx:32
Root namespace for the PLCnext API
This class implements the singleton pattern for singletons with process wide scope.
Definition: AppDomainSingleton.hxx:24
System components used by the System, Device, Plc or Io domains.
Definition: LogAdapter.hpp:14
Definition: LoggerBase.hxx:26