PLCnext API Documentation 25.0.2.69
Loggable.hxx
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Core/TypeName.hxx"
9#include "Arp/System/Commons/Diagnostics/Logging/Logger.hxx"
10
11namespace Arp { namespace System { namespace Commons { namespace Diagnostics { namespace Logging
12{
13
15//----------- Primary template of class Loggable<T, bool, bool> ---------------
17
26template<class T, bool IsSingleton = false, bool IsStaticClass = false>
28{
29protected: // construction
30 Loggable(void) = default;
31
32protected: // static fields
33 static Logger<T> log;
34};
35
37// Initializing of static member of class Loggable<T, bool, bool>
38template<class T, bool IsSingleton, bool IsStaticClass>
40
41
43//------- Template specialization Loaggable<T, true> for singletons -----------
45
54template<class T>
55class Loggable<T, true>
56{
57protected: // construction
58 Loggable(void) = default;
59
60protected: // fields
61 // use non static field here in specialization to avoid explicit logger initialization
62 Logger<T> log;
63};
64
66//---- Template specialization Loggable<T, false, true> for static classes ----
68
77template<class T>
78class Loggable<T, false, true>
79{
80public: // static operation
81 static void InitializeLogger(void);
82
83protected: // construction
84 Loggable(void) = default;
85
86protected: // fields
87 static Logger<T> log;
88};
89
91// inline methods of class Loggable<T, false, true>
92
97template<class T>
99{
101}
102
104// Initializing of static member of class Loggable<T, false, true>
105template<class T>
107
108}}}}} // end of namespace Arp::System::Commons::Diagnostics::Logging
This (meta programming) class provides the type-name according the CLS (common language specification...
Definition: CommonTypeName.hxx:33
Derive from this class to inherit logging functionality.
Definition: Loggable.hxx:28
void InitializeOnce(const String &loggerName)
Lazy initializes this logger instance once.
Definition: LoggerBase.cpp:73
Root namespace for the PLCnext API