1 karl 1.12 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.9 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.6 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.9 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.11 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.12 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 kumpf 1.4 //
|
21 mike 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Sushma Fernandes, Hewlett-Packard Company (sushma_fernandes@hp.com)
33 //
|
34 a.arora 1.8 // Modified By: Amit K Arora, IBM (amita@in.ibm.com) for Bug#1527
|
35 kumpf 1.10 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
36 mike 1.2 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
39
40 #ifndef Pegasus_TraceFileHandler_h
41 #define Pegasus_TraceFileHandler_h
42
43 #include <cstdarg>
44 #include <cstdio>
45 #include <Pegasus/Common/String.h>
|
46 kumpf 1.5 #include <Pegasus/Common/Linkage.h>
|
47 mike 1.2
48 PEGASUS_NAMESPACE_BEGIN
49
50 /** TraceFileHandler implements logging of messages to file
51 */
52
53 class PEGASUS_COMMON_LINKAGE TraceFileHandler
54 {
55 private:
56
|
57 kumpf 1.10 /** Open the specified file in append mode and ensure the file owner and
58 permissions are appropriate.
59 @param fileName Full path of the file to open.
60 @return Handle to the opened file if successful, otherwise 0.
61 */
62 FILE* _openFile(const char* fileName);
63
|
64 mike 1.2 /* File path to write messages
65 */
66 char* _fileName;
67
|
68 a.arora 1.8 #ifdef PEGASUS_PLATFORM_LINUX_GENERIC_GNU
69 /* Base File path to write messages
70 */
71 char* _baseFileName;
72
73 /* Count for the suffix of the trace file
74 */
75 Uint32 _fileCount;
76 #endif
77
|
78 mike 1.2 /* Handle to the File
79 */
80 FILE* _fileHandle;
81
82 /* Flag to track writing of message to log
83 */
84 Boolean _wroteToLog;
85
86 public:
87
88 /** Writes message to file.
89 Implementation of this function is platform specific
90 @param message message to be written
91 @param fmt printf style format string
92 @param argList variable argument list
93 */
94 void handleMessage(const char* message,const char* fmt,va_list argList);
95
96 /** Sets the filename to the given filename and opens the file in append
97 mode
98 @param fileName full path of the file
99 mike 1.2 @return 0 if the function is successful in opening the file
100 1 if an error occurs while opening the file
101 */
102 Uint32 setFileName(const char* fileName);
103
104 /** Validates the File Path for the trace File
105 @param filePath full path of the file
106 @return 1 if the file path is valid
107 0 if the file path is invalid
108 */
109 Boolean isValidFilePath(const char* filePath);
110
111 TraceFileHandler();
112
113 ~TraceFileHandler();
|
114 kumpf 1.7
|
115 mike 1.2 };
116
117 PEGASUS_NAMESPACE_END
118
119 #endif /* Pegasus_TraceFileHandler_h */
|