108 void print_julong(julong value); |
108 void print_julong(julong value); |
109 |
109 |
110 // flushing |
110 // flushing |
111 virtual void flush() {} |
111 virtual void flush() {} |
112 virtual void write(const char* str, size_t len) = 0; |
112 virtual void write(const char* str, size_t len) = 0; |
113 virtual ~outputStream() {} // close properly on deletion |
113 virtual void rotate_log() {} // GC log rotation |
|
114 virtual ~outputStream() {} // close properly on deletion |
114 |
115 |
115 void dec_cr() { dec(); cr(); } |
116 void dec_cr() { dec(); cr(); } |
116 void inc_cr() { inc(); cr(); } |
117 void inc_cr() { inc(); cr(); } |
117 }; |
118 }; |
118 |
119 |
119 // standard output |
120 // standard output |
120 // ANSI C++ name collision |
121 // ANSI C++ name collision |
121 extern outputStream* tty; // tty output |
122 extern outputStream* tty; // tty output |
122 extern outputStream* gclog_or_tty; // stream for gc log if -Xloggc:<f>, or tty |
123 extern outputStream* gclog_or_tty; // stream for gc log if -Xloggc:<f>, or tty |
123 |
124 |
124 // advisory locking for the shared tty stream: |
125 // advisory locking for the shared tty stream: |
125 class ttyLocker: StackObj { |
126 class ttyLocker: StackObj { |
174 class fileStream : public outputStream { |
175 class fileStream : public outputStream { |
175 protected: |
176 protected: |
176 FILE* _file; |
177 FILE* _file; |
177 bool _need_close; |
178 bool _need_close; |
178 public: |
179 public: |
|
180 fileStream() { _file = NULL; _need_close = false; } |
179 fileStream(const char* file_name); |
181 fileStream(const char* file_name); |
180 fileStream(const char* file_name, const char* opentype); |
182 fileStream(const char* file_name, const char* opentype); |
181 fileStream(FILE* file) { _file = file; _need_close = false; } |
183 fileStream(FILE* file) { _file = file; _need_close = false; } |
182 ~fileStream(); |
184 ~fileStream(); |
183 bool is_open() const { return _file != NULL; } |
185 bool is_open() const { return _file != NULL; } |
206 bool is_open() const { return _fd != -1; } |
208 bool is_open() const { return _fd != -1; } |
207 void set_fd(int fd) { _fd = fd; _need_close = false; } |
209 void set_fd(int fd) { _fd = fd; _need_close = false; } |
208 int fd() const { return _fd; } |
210 int fd() const { return _fd; } |
209 virtual void write(const char* c, size_t len); |
211 virtual void write(const char* c, size_t len); |
210 void flush() {}; |
212 void flush() {}; |
|
213 }; |
|
214 |
|
215 class rotatingFileStream : public fileStream { |
|
216 protected: |
|
217 char* _file_name; |
|
218 jlong _bytes_writen; |
|
219 uintx _cur_file_num; // current logfile rotation number, from 0 to MaxGCLogFileNumbers-1 |
|
220 public: |
|
221 rotatingFileStream(const char* file_name); |
|
222 rotatingFileStream(const char* file_name, const char* opentype); |
|
223 rotatingFileStream(FILE* file) : fileStream(file) {} |
|
224 ~rotatingFileStream(); |
|
225 virtual void write(const char* c, size_t len); |
|
226 virtual void rotate_log(); |
211 }; |
227 }; |
212 |
228 |
213 void ostream_init(); |
229 void ostream_init(); |
214 void ostream_init_log(); |
230 void ostream_init_log(); |
215 void ostream_exit(); |
231 void ostream_exit(); |