Pleora Technologies Inc. eBUS SDK v5.1.10.4642 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 private:
51 
52  // Not implemented
53  PvLogger();
54  PvLogger( const PvLogger & );
55  const PvLogger &operator=( const PvLogger & );
56 
57  PtUtilsLib::Logger *mThis;
58 
59 };
60 
61 
62 #define PV_LOGINFO( logger, entry ) { \
63  std::stringstream lStr; lStr << entry; \
64  ( logger ).LogInfo( __FILE__, __LINE__, __FUNCTION__, lStr.str().c_str() ); }
65 
66 #define PV_LOGERROR( logger, entry ) { \
67  std::stringstream lStr; lStr << entry; \
68  ( logger ).LogError( __FILE__, __LINE__, __FUNCTION__, lStr.str().c_str() ); }
69 
70 #define PV_LOGANDRETURN( logger, result, entry ) { \
71  std::stringstream lStr; lStr << entry; \
72  ( logger ).LogError( __FILE__, __LINE__, __FUNCTION__, lStr.str().c_str() ); \
73  return PvResult( result, lStr.str().c_str() ); }
74 
75 #define PV_LOGWARNING( logger, entry ) { \
76  std::stringstream lStr; lStr << entry; \
77  ( logger ).LogWarning( __FILE__, __LINE__, __FUNCTION__, lStr.str().c_str() ); }
78 
79 #define PV_LOGCRITICAL( logger, entry ) { \
80  std::stringstream lStr; lStr << entry; \
81  ( logger ).LogCritical( __FILE__, __LINE__, __FUNCTION__, lStr.str().c_str() ); }
82 
83 #define PV_LOGDEBUG( logger, entry ) { \
84  std::stringstream lStr; lStr << entry; \
85  ( logger ).LogDebug( __FILE__, __LINE__, __FUNCTION__, lStr.str().c_str() ); }
86 
87 
88 class PV_BASE_API PvLogSink
89 {
90 public:
91 
92  PvLogSink();
93  virtual ~PvLogSink();
94 
95  virtual void Log( PvLogLevelEnum aLevel, const char *aFile, uint32_t aLine, const char *aFunction, const char *aCategory, const char *aMessage ) = 0;
96 
97 private:
98 
99  // Not implemented
100  PvLogSink( const PvLogSink & );
101  const PvLogSink &operator=( const PvLogSink & );
102 
103  PvBaseLib::LogSink *mThis;
104 
105 };
106 
107 #endif
Class used to register logging callbacks from your application.
Definition: PvLogger.h:88
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-2018 Pleora Technologies Inc.
www.pleora.com