Pleora Technologies Inc. eBUS SDK v6.2.8.5877 API



PvLogger.h
1 // *****************************************************************************
2 //
3 // Copyright (c) 2016, Pleora Technologies Inc., All rights reserved.
4 //
5 // *****************************************************************************
6 
7 #ifndef __PVLOGGER_H__
8 #define __PVLOGGER_H__
9 
10 #include <PvResult.h>
11 
12 #include <sstream>
13 
14 
15 namespace PtUtilsLib
16 {
17  class Logger;
18 }
19 
20 namespace PvBaseLib
21 {
22  class LogSink;
23 }
24 
25 
26 enum PvLogLevelEnum
27 {
28  PvLogLevelUnknown,
29  PvLogLevelInfo,
30  PvLogLevelError,
31  PvLogLevelWarning,
32  PvLogLevelCritical,
33  PvLogLevelDebug
34 };
35 
36 
37 class PV_BASE_API PvLogger
38 {
39 public:
40 
41  PvLogger( const PvString &aCategory );
42  virtual ~PvLogger();
43 
44  void LogInfo( const char *aFile, int aLine, const char *aFunction, const char *aMessage );
45  void LogError( const char *aFile, int aLine, const char *aFunction, const char *aMessage );
46  void LogWarning( const char *aFile, int aLine, const char *aFunction, const char *aMessage );
47  void LogCritical( const char *aFile, int aLine, const char *aFunction, const char *aMessage );
48  void LogDebug( const char *aFile, int aLine, const char *aFunction, const char *aMessage );
49 
50  void SetLogPriority( int32_t aLevel );
51  int32_t GetLogPriority();
52 
53 private:
54 
55  // Not implemented
56  PvLogger();
57  PvLogger( const PvLogger & );
58  const PvLogger &operator=( const PvLogger & );
59 
60  PtUtilsLib::Logger *mThis;
61 
62 };
63 
64 
65 #define PV_LOGINFO( logger, entry ) { \
66  std::stringstream lStrXTemp; lStrXTemp << entry; \
67  ( logger ).LogInfo( __FILE__, __LINE__, __FUNCTION__, lStrXTemp.str().c_str() ); }
68 
69 #define PV_LOGERROR( logger, entry ) { \
70  std::stringstream lStrXTemp; lStrXTemp << entry; \
71  ( logger ).LogError( __FILE__, __LINE__, __FUNCTION__, lStrXTemp.str().c_str() ); }
72 
73 #define PV_LOGANDRETURN( logger, result, entry ) { \
74  std::stringstream lStrXTemp; lStrXTemp << entry; \
75  ( logger ).LogError( __FILE__, __LINE__, __FUNCTION__, lStrXTemp.str().c_str() ); \
76  return PvResult( result, lStrXTemp.str().c_str() ); }
77 
78 #define PV_LOGWARNING( logger, entry ) { \
79  std::stringstream lStrXTemp; lStrXTemp << entry; \
80  ( logger ).LogWarning( __FILE__, __LINE__, __FUNCTION__, lStrXTemp.str().c_str() ); }
81 
82 #define PV_LOGCRITICAL( logger, entry ) { \
83  std::stringstream lStrXTemp; lStrXTemp << entry; \
84  ( logger ).LogCritical( __FILE__, __LINE__, __FUNCTION__, lStrXTemp.str().c_str() ); }
85 
86 #define PV_LOGDEBUG( logger, entry ) { \
87  std::stringstream lStrXTemp; lStrXTemp << entry; \
88  ( logger ).LogDebug( __FILE__, __LINE__, __FUNCTION__, lStrXTemp.str().c_str() ); }
89 
90 
91 class PV_BASE_API PvLogSink
92 {
93 public:
94 
95  PvLogSink();
96  virtual ~PvLogSink();
97 
98  virtual void Log( PvLogLevelEnum aLevel, const char *aFile, uint32_t aLine, const char *aFunction, const char *aCategory, const char *aMessage ) = 0;
99 
100 private:
101 
102  // Not implemented
103  PvLogSink( const PvLogSink & );
104  const PvLogSink &operator=( const PvLogSink & );
105 
106  PvBaseLib::LogSink *mThis;
107 
108 };
109 
110 #endif
Class used to register logging callbacks from your application.
Definition: PvLogger.h:91
Used to log information or events in some logging category.
Definition: PvLogger.h:37
String class.
Definition: PvString.h:21
Definition: PvDfwPayload.h:15
Definition: PvDeviceAdapter.h:16

Copyright (c) 2002-2021 Pleora Technologies Inc.
www.pleora.com