148 void date_stamp(bool guard) {
149 date_stamp(guard, "", ": ");
150 }
151
152 // portable printing of 64 bit integers
153 void print_jlong(jlong value);
154 void print_julong(julong value);
155
156 // flushing
157 virtual void flush() {}
158 virtual void write(const char* str, size_t len) = 0;
159 virtual void rotate_log(bool force, outputStream* out = nullptr) {} // GC log rotation
160 virtual ~outputStream() {} // close properly on deletion
161
162 // Caller may specify their own scratch buffer to use for printing; otherwise,
163 // an automatic buffer on the stack (with O_BUFLEN len) is used.
164 void set_scratch_buffer(char* p, size_t len) { _scratch = p; _scratch_len = len; }
165
166 void dec_cr() { dec(); cr(); }
167 void inc_cr() { inc(); cr(); }
168 };
169
170 // standard output
171 // ANSI C++ name collision
172 extern outputStream* tty; // tty output
173
174 // outputStream indentation. When used, indentation is automatically applied
175 // when printing on the stream using the following APIs:
176 // print(), print_cr(), print_raw(), print_raw_cr()
177 class StreamIndentor {
178 private:
179 outputStream* const _stream;
180 const int _indentation;
181 const bool _old_autoindent;
182 NONCOPYABLE(StreamIndentor);
183
184 public:
185 StreamIndentor(outputStream* os, int indentation) :
186 _stream(os),
187 _indentation(indentation),
|
148 void date_stamp(bool guard) {
149 date_stamp(guard, "", ": ");
150 }
151
152 // portable printing of 64 bit integers
153 void print_jlong(jlong value);
154 void print_julong(julong value);
155
156 // flushing
157 virtual void flush() {}
158 virtual void write(const char* str, size_t len) = 0;
159 virtual void rotate_log(bool force, outputStream* out = nullptr) {} // GC log rotation
160 virtual ~outputStream() {} // close properly on deletion
161
162 // Caller may specify their own scratch buffer to use for printing; otherwise,
163 // an automatic buffer on the stack (with O_BUFLEN len) is used.
164 void set_scratch_buffer(char* p, size_t len) { _scratch = p; _scratch_len = len; }
165
166 void dec_cr() { dec(); cr(); }
167 void inc_cr() { inc(); cr(); }
168
169 // Append strings returned by gen, separating each with separator.
170 // Stops when gen returns null.
171 template <typename Generator>
172 void join(Generator gen, const char* separator) {
173 bool first = true;
174 const char* str = gen();
175 while (str != nullptr) {
176 const char* sep = first ? "" : separator;
177 print("%s%s", sep, str);
178 first = false;
179 str = gen();
180 }
181 }
182 };
183
184 // standard output
185 // ANSI C++ name collision
186 extern outputStream* tty; // tty output
187
188 // outputStream indentation. When used, indentation is automatically applied
189 // when printing on the stream using the following APIs:
190 // print(), print_cr(), print_raw(), print_raw_cr()
191 class StreamIndentor {
192 private:
193 outputStream* const _stream;
194 const int _indentation;
195 const bool _old_autoindent;
196 NONCOPYABLE(StreamIndentor);
197
198 public:
199 StreamIndentor(outputStream* os, int indentation) :
200 _stream(os),
201 _indentation(indentation),
|