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