Path: blob/master/runtime/gc_verbose_old/VerboseFileLoggingOutput.hpp
5985 views
1/*******************************************************************************2* Copyright (c) 1991, 2019 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* distribution and is available at https://www.eclipse.org/legal/epl-2.0/7* or the Apache License, Version 2.0 which accompanies this distribution and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*20* 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-exception21*******************************************************************************/2223#if !defined(FILE_LOG_OUTPUT_HPP_)24#define FILE_LOG_OUTPUT_HPP_2526#include "j9.h"27#include "j9cfg.h"2829#include "VerboseOutputAgent.hpp"3031#define VGC_INPUT_STRING_SIZE 25632#define VGC_INDENT_SPACER " "3334enum {35single_file = 0,36rotating_files37};3839/**40* Output agent which directs verbosegc output to file.41*/42class MM_VerboseFileLoggingOutput : public MM_VerboseOutputAgent43{44/* fields */45public:46protected:47private:48char *_filename; /**< the filename template supplied from the command line */49UDATA _numFiles; /**< number of files to rotate through */50UDATA _numCycles; /**< number of cycles in each file */5152UDATA _mode; /**< rotation mode -- single_file or rotating_files */53UDATA _currentFile; /**< zero-based index of current rotating file */54UDATA _currentCycle; /**< current GC cycle within this file */5556IDATA _logFileDescriptor; /**< the file being written to */5758J9StringTokens *_tokens; /**< tokens used during filename expansion */5960/* methods */61public:62virtual void formatAndOutput(J9VMThread *vmThread, UDATA indent, const char *format, ...);6364virtual bool reconfigure(MM_EnvironmentBase *env, const char* filename, UDATA fileCount, UDATA iterations);6566bool openFile(MM_EnvironmentBase *env);67void closeFile(MM_EnvironmentBase *env);6869void closeStream(MM_EnvironmentBase *env);7071virtual void endOfCycle(J9VMThread *vmThread);7273static MM_VerboseFileLoggingOutput *newInstance(MM_EnvironmentBase *env, char* filename, UDATA fileCount, UDATA iterations);7475MM_VerboseFileLoggingOutput(MM_EnvironmentBase *env)76: MM_VerboseOutputAgent(env, FILE_LOGGING)77, _filename(NULL)78, _mode(single_file)79, _currentFile(0)80, _currentCycle(0)81, _logFileDescriptor(-1)82, _tokens(NULL)83{}8485protected:8687private:88bool initialize(MM_EnvironmentBase *env, const char *filename, UDATA numFiles, UDATA numCycles);89virtual void tearDown(MM_EnvironmentBase *env);90IDATA findInitialFile(MM_EnvironmentBase *env);91bool initializeFilename(MM_EnvironmentBase *env, const char *filename);92bool initializeTokens(MM_EnvironmentBase *env);93char* expandFilename(MM_EnvironmentBase *env, UDATA currentFile);9495};9697#endif /* FILE_LOG_OUTPUT_HPP_ */9899100