-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrace.cpp
134 lines (113 loc) · 3.12 KB
/
Trace.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//////////////////////////////////////////////////////////////////////////////
//****************************************************************************
//
// FILE NAME: Trace.cpp
//
// DECSRIPTION: This is the source file for trace functionality
//
// CHANGE ACTIVITY:
// Date Who Description
// ========== ======= ===============
//
//****************************************************************************
//////////////////////////////////////////////////////////////////////////////
/*
* Header files
*/
#include "Trace.h"
/*****************************************************************
* NAME: traceFileCreate
*
* DESCRIPTION: Function creates a trace file
*
* RETURN:
* (int) SUCCESS
* ERROR otherwise
*
****************************************************************/
int Trace::traceFileCreate() {
int rc = SUCCESS; // Return code
logF = fopen(LOG_FILE_LOCATION, "w");
if ( NULL == logF )
{
printf("\nUnable to open log file in write mode\n");
rc = FAILURE;
}
return rc;
}
/*****************************************************************
* NAME: printToTrace
*
* DESCRIPTION: Function takes care of writing into log
*
* PARAMETERS:
* (char *) keyMsg - buffer to be written as key
* (char *) valueMsg - buffer to be written as value
*
* RETURN:
* (int) SUCCESS
* FAILURE otherwise
*
****************************************************************/
int Trace::printToTrace(char *keyMsg, char *valueMsg) {
int rc = SUCCESS; // Return code
fprintf(logF, "%s : %s\n", keyMsg, valueMsg);
fflush(logF);
return rc;
}
/*****************************************************************
* NAME: traceFileClose
*
* DESCRIPTION: Function takes care of closing log
*
* RETURN:
* (int) SUCCESS
* ERROR otherwise
*
****************************************************************/
int Trace::traceFileClose() {
int rc = SUCCESS;
fclose(logF);
return rc;
}
/*****************************************************************
* NAME: funcEntry
*
* DESCRIPTION: Logs function entry
*
* PARAMETERS:
* (char *) keyMsg - ipAddress
* (char *) valueMsg - funcName
*
* RETURN:
* (int) ZERO if success
* ERROR otherwise
*
****************************************************************/
int Trace::funcEntry(char *funcName) {
int rc = SUCCESS; // Return code
fprintf(logF, "ENTRY - %s\n", funcName);
fflush(logF);
return rc;
}
/*****************************************************************
* NAME: funcExit
*
* DESCRIPTION: Logs function exit
*
* PARAMETERS:
* (char *) keyMsg - ipAddress
* (char *) valueMsg - funcName
* (int) f_rc - return code of function
*
* RETURN:
* (int) ZERO if success
* ERROR otherwise
*
****************************************************************/
int Trace::funcExit(char *funcName, int f_rc) {
int rc = SUCCESS; // Return code
fprintf(logF, "EXIT - %s with rc = %d\n", funcName, f_rc);
fflush(logF);
return rc;
}