218 // error handler.
219 class fdStream : public outputStream {
220 protected:
221 int _fd;
222 bool _need_close;
223 public:
224 fdStream(const char* file_name);
225 fdStream(int fd = -1) { _fd = fd; _need_close = false; }
226 ~fdStream();
227 bool is_open() const { return _fd != -1; }
228 void set_fd(int fd) { _fd = fd; _need_close = false; }
229 int fd() const { return _fd; }
230 virtual void write(const char* c, size_t len);
231 void flush() {};
232 };
233
234 class rotatingFileStream : public fileStream {
235 protected:
236 char* _file_name;
237 jlong _bytes_written;
238 uintx _cur_file_num; // current logfile rotation number, from 0 to MaxGCLogFileNumbers-1
239 public:
240 rotatingFileStream(const char* file_name);
241 rotatingFileStream(const char* file_name, const char* opentype);
242 rotatingFileStream(FILE* file) : fileStream(file) {}
243 ~rotatingFileStream();
244 virtual void write(const char* c, size_t len);
245 virtual void rotate_log();
246 };
247
248 void ostream_init();
249 void ostream_init_log();
250 void ostream_exit();
251 void ostream_abort();
252
253 // staticBufferStream uses a user-supplied buffer for all formatting.
254 // Used for safe formatting during fatal error handling. Not MT safe.
255 // Do not share the stream between multiple threads.
256 class staticBufferStream : public outputStream {
257 private:
258 char* _buffer;
259 size_t _buflen;
260 outputStream* _outer_stream;
261 public:
262 staticBufferStream(char* buffer, size_t buflen,
|
218 // error handler.
219 class fdStream : public outputStream {
220 protected:
221 int _fd;
222 bool _need_close;
223 public:
224 fdStream(const char* file_name);
225 fdStream(int fd = -1) { _fd = fd; _need_close = false; }
226 ~fdStream();
227 bool is_open() const { return _fd != -1; }
228 void set_fd(int fd) { _fd = fd; _need_close = false; }
229 int fd() const { return _fd; }
230 virtual void write(const char* c, size_t len);
231 void flush() {};
232 };
233
234 class rotatingFileStream : public fileStream {
235 protected:
236 char* _file_name;
237 jlong _bytes_written;
238 uintx _cur_file_num; // current logfile rotation number, from 0 to NumberOfGCLogFiles-1
239 public:
240 rotatingFileStream(const char* file_name);
241 ~rotatingFileStream();
242 virtual void write(const char* c, size_t len);
243 virtual void rotate_log();
244 };
245
246 void ostream_init();
247 void ostream_init_log();
248 void ostream_exit();
249 void ostream_abort();
250
251 // staticBufferStream uses a user-supplied buffer for all formatting.
252 // Used for safe formatting during fatal error handling. Not MT safe.
253 // Do not share the stream between multiple threads.
254 class staticBufferStream : public outputStream {
255 private:
256 char* _buffer;
257 size_t _buflen;
258 outputStream* _outer_stream;
259 public:
260 staticBufferStream(char* buffer, size_t buflen,
|