1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | |
6 | #ifndef __EVENTPIPE_JSONFILE_H__ |
7 | #define __EVENTPIPE_JSONFILE_H__ |
8 | |
9 | #ifdef _DEBUG |
10 | #ifdef FEATURE_PERFTRACING |
11 | |
12 | #include "common.h" |
13 | #include "eventpipe.h" |
14 | #include "eventpipeeventinstance.h" |
15 | #include "fstream.h" |
16 | |
17 | class EventPipeJsonFile |
18 | { |
19 | public: |
20 | EventPipeJsonFile(SString &outFilePath); |
21 | ~EventPipeJsonFile(); |
22 | |
23 | // Write an event instance. |
24 | void WriteEvent(EventPipeEventInstance &instance); |
25 | |
26 | // Write an event with the specified message and stack. |
27 | void WriteEvent(LARGE_INTEGER timeStamp, DWORD threadID, SString &message, StackContents &stackContents); |
28 | |
29 | private: |
30 | |
31 | // Write a string to the file. |
32 | void Write(SString &str); |
33 | |
34 | // Format the input callstack for printing. |
35 | void FormatCallStack(StackContents &stackContents, SString &resultStr); |
36 | |
37 | // The output file stream. |
38 | CFileStream *m_pFileStream; |
39 | |
40 | // Keep track of if an error has been encountered while writing. |
41 | bool m_writeErrorEncountered; |
42 | |
43 | // File-open timestamp for use when calculating event timestamps. |
44 | LARGE_INTEGER m_fileOpenTimeStamp; |
45 | }; |
46 | |
47 | #endif // FEATURE_PERFTRACING |
48 | #endif // _DEBUG |
49 | |
50 | #endif // __EVENTPIPE_JSONFILE_H__ |
51 | |