/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_UTILITIES_OSTREAM_HPP
#define SHARE_VM_UTILITIES_OSTREAM_HPP
#include "memory/allocation.hpp"
// Output streams for printing
//
// Printing guidelines:
// Where possible, please use tty->print() and tty->print_cr().
// For product mode VM warnings use warning() which internally uses tty.
// In places where tty is not initialized yet or too much overhead,
// we may use jio_printf:
// jio_fprintf(defaultStream::output_stream(), "Message");
// This allows for redirection via -XX:+DisplayVMOutputToStdout and
// -XX:+DisplayVMOutputToStderr
protected:
bool add_cr,
size_t& result_len);
public:
// creation
// indentation
outputStream& indent();
// sizing
// printing
void cr();
// Time stamp
void stamp();
}
// Date stamp
// A simplified call that includes a suffix of ": "
}
// portable printing of 64 bit integers
// flushing
virtual void flush() {}
virtual ~outputStream() {} // close properly on deletion
};
// standard output
// ANSI C++ name collision
private:
int _amount;
public:
}
};
// advisory locking for the shared tty stream:
friend class ttyUnlocker;
private:
public:
static bool release_tty_if_locked(); // returns true if lock was released
};
// Release the tty lock if it's held and reacquire it if it was
// locked. Used to avoid lock ordering problems.
private:
bool _was_locked;
public:
ttyUnlocker() {
}
~ttyUnlocker() {
if (_was_locked) {
}
}
};
// for writing to strings; buffer will expand automatically
protected:
char* buffer;
bool buffer_fixed;
public:
~stringStream();
char* as_string();
};
protected:
bool _need_close;
public:
fileStream(const char* file_name);
~fileStream();
long fileSize();
void flush();
};
// unlike fileStream, fdStream does unbuffered I/O by calling
// open() and write() directly. It is async-safe, but output
// from multiple thread may be mixed together. Used by fatal
// error handler.
protected:
int _fd;
bool _need_close;
public:
~fdStream();
void flush() {};
};
protected:
char* _file_name;
public:
rotatingFileStream(const char* file_name);
virtual void rotate_log();
};
void ostream_init();
void ostream_init_log();
void ostream_exit();
void ostream_abort();
// staticBufferStream uses a user-supplied buffer for all formatting.
// Used for safe formatting during fatal error handling. Not MT safe.
// Do not share the stream between multiple threads.
private:
char* _buffer;
public:
~staticBufferStream() {};
void flush();
};
// In the non-fixed buffer case an underlying buffer will be created and
// managed in C heap. Not MT-safe.
protected:
char* buffer;
bool buffer_fixed;
public:
~bufferedStream();
char* as_string();
};
#ifndef PRODUCT
private:
int _socket;
public:
~networkStream();
void close();
virtual void flush();
};
#endif
#endif // SHARE_VM_UTILITIES_OSTREAM_HPP