1 /*****************************************************************************/
2 /* Software Testing Automation Framework (STAF)                              */
3 /* (C) Copyright IBM Corp. 2001                                              */
4 /*                                                                           */
5 /* This software is licensed under the Eclipse Public License (EPL) V1.0.    */
6 /*****************************************************************************/
7 
8 #ifndef STAF_TraceInlImpl
9 #define STAF_TraceInlImpl
10 
11 #include "STAF.h"
12 #include "STAFTrace.h"
13 
traceOn(STAFTracePoint_t mask)14 STAF_INLINE void STAFTrace::traceOn(STAFTracePoint_t mask)
15 {
16     STAFTraceEnableTracePoints(mask);
17 }
18 
19 
traceOff(STAFTracePoint_t mask)20 STAF_INLINE void STAFTrace::traceOff(STAFTracePoint_t mask)
21 {
22     STAFTraceDisableTracePoints(mask);
23 }
24 
25 
getTraceMask()26 STAF_INLINE STAFTracePoint_t STAFTrace::getTraceMask()
27 {
28     return STAFTraceGetEnabledTracePoints();
29 }
30 
31 
32 STAF_INLINE STAFRC_t
setTraceDestination(STAFTraceDestination_t traceDestination,const STAFString & filename,STAFTraceFileMode_t traceFileMode,unsigned int * osRC)33 STAFTrace::setTraceDestination(STAFTraceDestination_t traceDestination,
34                                const STAFString &filename,
35                                STAFTraceFileMode_t traceFileMode,
36                                unsigned int *osRC)
37 {
38     return STAFTraceSetTraceDestination(traceDestination,
39                                         filename.getImpl(),
40                                         traceFileMode,
41                                         osRC);
42 }
43 
44 
45 STAF_INLINE STAFTraceDestination_t
getTraceDestination(STAFString & filename)46 STAFTrace::getTraceDestination(STAFString &filename)
47 {
48     STAFTraceDestination_t traceDestination = kSTAFTraceToStdout;
49     STAFString_t filenameImpl = 0;
50     STAFRC_t rc = STAFTraceGetTraceDestination(&traceDestination,
51                                                &filenameImpl,
52                                                0);
53 
54     if (filenameImpl != 0)
55         filename = STAFString(filenameImpl, STAFString::kShallow);
56 
57     return traceDestination;
58 }
59 
60 
61 STAF_INLINE STAFTraceFileMode_t
getTraceFileMode()62 STAFTrace::getTraceFileMode()
63 {
64     STAFTraceFileMode_t traceFileMode = kSTAFTraceFileReplace;
65 
66     STAFRC_t rc = STAFTraceGetTraceFileMode(&traceFileMode, 0);
67 
68     return traceFileMode;
69 }
70 
71 
doTrace(STAFTracePoint_t tracePoint)72 STAF_INLINE bool STAFTrace::doTrace(STAFTracePoint_t tracePoint)
73 {
74     return ((tracePoint != 0) &&
75             ((tracePoint & STAFTraceGetEnabledTracePoints()) == tracePoint));
76 }
77 
trace(STAFTracePoint_t tracePoint,const char * message)78 STAF_INLINE STAFRC_t STAFTrace::trace(STAFTracePoint_t tracePoint,
79                                       const char *message)
80 {
81     return STAFTraceLogCStringMessage(tracePoint, message, 0);
82 }
83 
84 
trace(STAFTracePoint_t tracePoint,const STAFString & message)85 STAF_INLINE STAFRC_t STAFTrace::trace(STAFTracePoint_t tracePoint,
86                                       const STAFString &message)
87 {
88     return STAFTraceLogSTAFStringMessage(tracePoint, message.getImpl(), 0);
89 }
90 
91 #endif
92