Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_verbose_old/VerboseFileLoggingOutput.hpp
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2019 IBM Corp. and others
4
*
5
* This program and the accompanying materials are made available under
6
* the terms of the Eclipse Public License 2.0 which accompanies this
7
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
8
* or the Apache License, Version 2.0 which accompanies this distribution and
9
* is available at https://www.apache.org/licenses/LICENSE-2.0.
10
*
11
* This Source Code may also be made available under the following
12
* Secondary Licenses when the conditions for such availability set
13
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
14
* General Public License, version 2 with the GNU Classpath
15
* Exception [1] and GNU General Public License, version 2 with the
16
* OpenJDK Assembly Exception [2].
17
*
18
* [1] https://www.gnu.org/software/classpath/license.html
19
* [2] http://openjdk.java.net/legal/assembly-exception.html
20
*
21
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
22
*******************************************************************************/
23
24
#if !defined(FILE_LOG_OUTPUT_HPP_)
25
#define FILE_LOG_OUTPUT_HPP_
26
27
#include "j9.h"
28
#include "j9cfg.h"
29
30
#include "VerboseOutputAgent.hpp"
31
32
#define VGC_INPUT_STRING_SIZE 256
33
#define VGC_INDENT_SPACER " "
34
35
enum {
36
single_file = 0,
37
rotating_files
38
};
39
40
/**
41
* Output agent which directs verbosegc output to file.
42
*/
43
class MM_VerboseFileLoggingOutput : public MM_VerboseOutputAgent
44
{
45
/* fields */
46
public:
47
protected:
48
private:
49
char *_filename; /**< the filename template supplied from the command line */
50
UDATA _numFiles; /**< number of files to rotate through */
51
UDATA _numCycles; /**< number of cycles in each file */
52
53
UDATA _mode; /**< rotation mode -- single_file or rotating_files */
54
UDATA _currentFile; /**< zero-based index of current rotating file */
55
UDATA _currentCycle; /**< current GC cycle within this file */
56
57
IDATA _logFileDescriptor; /**< the file being written to */
58
59
J9StringTokens *_tokens; /**< tokens used during filename expansion */
60
61
/* methods */
62
public:
63
virtual void formatAndOutput(J9VMThread *vmThread, UDATA indent, const char *format, ...);
64
65
virtual bool reconfigure(MM_EnvironmentBase *env, const char* filename, UDATA fileCount, UDATA iterations);
66
67
bool openFile(MM_EnvironmentBase *env);
68
void closeFile(MM_EnvironmentBase *env);
69
70
void closeStream(MM_EnvironmentBase *env);
71
72
virtual void endOfCycle(J9VMThread *vmThread);
73
74
static MM_VerboseFileLoggingOutput *newInstance(MM_EnvironmentBase *env, char* filename, UDATA fileCount, UDATA iterations);
75
76
MM_VerboseFileLoggingOutput(MM_EnvironmentBase *env)
77
: MM_VerboseOutputAgent(env, FILE_LOGGING)
78
, _filename(NULL)
79
, _mode(single_file)
80
, _currentFile(0)
81
, _currentCycle(0)
82
, _logFileDescriptor(-1)
83
, _tokens(NULL)
84
{}
85
86
protected:
87
88
private:
89
bool initialize(MM_EnvironmentBase *env, const char *filename, UDATA numFiles, UDATA numCycles);
90
virtual void tearDown(MM_EnvironmentBase *env);
91
IDATA findInitialFile(MM_EnvironmentBase *env);
92
bool initializeFilename(MM_EnvironmentBase *env, const char *filename);
93
bool initializeTokens(MM_EnvironmentBase *env);
94
char* expandFilename(MM_EnvironmentBase *env, UDATA currentFile);
95
96
};
97
98
#endif /* FILE_LOG_OUTPUT_HPP_ */
99
100