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

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