< prev index next >

src/share/vm/utilities/ostream.hpp

Print this page




  91    void print_raw_cr(const char* str, int len){ write(str,         len); cr(); }
  92    void print_data(void* data, size_t len, bool with_ascii);
  93    void put(char ch);
  94    void sp(int count = 1);
  95    void cr();
  96    void bol() { if (_position > 0)  cr(); }
  97 
  98    // Time stamp
  99    TimeStamp& time_stamp() { return _stamp; }
 100    void stamp();
 101    void stamp(bool guard, const char* prefix, const char* suffix);
 102    void stamp(bool guard) {
 103      stamp(guard, "", ": ");
 104    }
 105    // Date stamp
 106    void date_stamp(bool guard, const char* prefix, const char* suffix);
 107    // A simplified call that includes a suffix of ": "
 108    void date_stamp(bool guard) {
 109      date_stamp(guard, "", ": ");
 110    }
 111    void gclog_stamp();
 112 
 113    // portable printing of 64 bit integers
 114    void print_jlong(jlong value);
 115    void print_julong(julong value);
 116 
 117    // flushing
 118    virtual void flush() {}
 119    virtual void write(const char* str, size_t len) = 0;
 120    virtual void rotate_log(bool force, outputStream* out = NULL) {} // GC log rotation
 121    virtual ~outputStream() {}   // close properly on deletion
 122 
 123    void dec_cr() { dec(); cr(); }
 124    void inc_cr() { inc(); cr(); }
 125 };
 126 
 127 // standard output
 128 // ANSI C++ name collision
 129 extern outputStream* tty;           // tty output
 130 extern outputStream* gclog_or_tty;  // stream for gc log if -Xloggc:<f>, or tty
 131 
 132 class streamIndentor : public StackObj {
 133  private:
 134   outputStream* _str;
 135   int _amount;
 136 
 137  public:
 138   streamIndentor(outputStream* str, int amt = 2) : _str(str), _amount(amt) {
 139     _str->inc(_amount);
 140   }
 141   ~streamIndentor() { _str->dec(_amount); }
 142 };
 143 
 144 
 145 // advisory locking for the shared tty stream:
 146 class ttyLocker: StackObj {
 147   friend class ttyUnlocker;
 148  private:
 149   intx _holder;
 150 


 229   fdStream(int fd = -1) { _fd = fd; _need_close = false; }
 230   ~fdStream();
 231   bool is_open() const { return _fd != -1; }
 232   void set_fd(int fd) { _fd = fd; _need_close = false; }
 233   int fd() const { return _fd; }
 234   virtual void write(const char* c, size_t len);
 235   void flush() {};
 236 };
 237 
 238 class logStream : public outputStream {
 239 private:
 240   stringStream _current_line;
 241   void (*_log_func)(const char* fmt, ...);
 242 public:
 243   void write(const char* s, size_t len);
 244   logStream(void (*log_func)(const char* fmt, ...)) : _log_func(log_func) {}
 245   ~logStream() {
 246     guarantee(_current_line.size() == 0, "Buffer not flushed. Missing call to print_cr()?");
 247   }
 248 };
 249 
 250 class gcLogFileStream : public fileStream {
 251  protected:
 252   const char*  _file_name;
 253   jlong  _bytes_written;
 254   uintx  _cur_file_num;             // current logfile rotation number, from 0 to NumberOfGCLogFiles-1
 255  public:
 256   gcLogFileStream(const char* file_name);
 257   ~gcLogFileStream();
 258   virtual void write(const char* c, size_t len);
 259   virtual void rotate_log(bool force, outputStream* out = NULL);
 260   void dump_loggc_header();
 261 
 262   /* If "force" sets true, force log file rotation from outside JVM */
 263   bool should_rotate(bool force) {
 264     return force ||
 265              ((GCLogFileSize != 0) && (_bytes_written >= (jlong)GCLogFileSize));
 266   }
 267 };
 268 
 269 #ifndef PRODUCT
 270 // unit test for checking -Xloggc:<filename> parsing result
 271 void test_loggc_filename();
 272 #endif
 273 
 274 void ostream_init();
 275 void ostream_init_log();
 276 void ostream_exit();
 277 void ostream_abort();
 278 
 279 // staticBufferStream uses a user-supplied buffer for all formatting.
 280 // Used for safe formatting during fatal error handling.  Not MT safe.
 281 // Do not share the stream between multiple threads.
 282 class staticBufferStream : public outputStream {
 283  private:
 284   char* _buffer;
 285   size_t _buflen;
 286   outputStream* _outer_stream;
 287  public:
 288   staticBufferStream(char* buffer, size_t buflen,
 289                      outputStream *outer_stream);
 290   ~staticBufferStream() {};
 291   virtual void write(const char* c, size_t len);
 292   void flush();




  91    void print_raw_cr(const char* str, int len){ write(str,         len); cr(); }
  92    void print_data(void* data, size_t len, bool with_ascii);
  93    void put(char ch);
  94    void sp(int count = 1);
  95    void cr();
  96    void bol() { if (_position > 0)  cr(); }
  97 
  98    // Time stamp
  99    TimeStamp& time_stamp() { return _stamp; }
 100    void stamp();
 101    void stamp(bool guard, const char* prefix, const char* suffix);
 102    void stamp(bool guard) {
 103      stamp(guard, "", ": ");
 104    }
 105    // Date stamp
 106    void date_stamp(bool guard, const char* prefix, const char* suffix);
 107    // A simplified call that includes a suffix of ": "
 108    void date_stamp(bool guard) {
 109      date_stamp(guard, "", ": ");
 110    }

 111 
 112    // portable printing of 64 bit integers
 113    void print_jlong(jlong value);
 114    void print_julong(julong value);
 115 
 116    // flushing
 117    virtual void flush() {}
 118    virtual void write(const char* str, size_t len) = 0;
 119    virtual void rotate_log(bool force, outputStream* out = NULL) {} // GC log rotation
 120    virtual ~outputStream() {}   // close properly on deletion
 121 
 122    void dec_cr() { dec(); cr(); }
 123    void inc_cr() { inc(); cr(); }
 124 };
 125 
 126 // standard output
 127 // ANSI C++ name collision
 128 extern outputStream* tty;           // tty output

 129 
 130 class streamIndentor : public StackObj {
 131  private:
 132   outputStream* _str;
 133   int _amount;
 134 
 135  public:
 136   streamIndentor(outputStream* str, int amt = 2) : _str(str), _amount(amt) {
 137     _str->inc(_amount);
 138   }
 139   ~streamIndentor() { _str->dec(_amount); }
 140 };
 141 
 142 
 143 // advisory locking for the shared tty stream:
 144 class ttyLocker: StackObj {
 145   friend class ttyUnlocker;
 146  private:
 147   intx _holder;
 148 


 227   fdStream(int fd = -1) { _fd = fd; _need_close = false; }
 228   ~fdStream();
 229   bool is_open() const { return _fd != -1; }
 230   void set_fd(int fd) { _fd = fd; _need_close = false; }
 231   int fd() const { return _fd; }
 232   virtual void write(const char* c, size_t len);
 233   void flush() {};
 234 };
 235 
 236 class logStream : public outputStream {
 237 private:
 238   stringStream _current_line;
 239   void (*_log_func)(const char* fmt, ...);
 240 public:
 241   void write(const char* s, size_t len);
 242   logStream(void (*log_func)(const char* fmt, ...)) : _log_func(log_func) {}
 243   ~logStream() {
 244     guarantee(_current_line.size() == 0, "Buffer not flushed. Missing call to print_cr()?");
 245   }
 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,
 263                      outputStream *outer_stream);
 264   ~staticBufferStream() {};
 265   virtual void write(const char* c, size_t len);
 266   void flush();


< prev index next >