Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
Save and restore outputstream formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlau committed Mar 28, 2017
1 parent 08388f1 commit d3b8a03
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,11 @@ static void walkHandle(uv_handle_t* h, void* arg) {

*out << std::left << "[" << (uv_has_ref(h) ? 'R' : '-')
<< (uv_is_active(h) ? 'A' : '-') << "] " << std::setw(10) << type
<< std::internal << std::setw(2 + 2 * sizeof(void*)) << std::setfill('0')
<< static_cast<void*>(h) << std::left << std::setfill(' ') << " "
<< std::left << data.str() << std::endl;
<< std::internal << std::setw(2 + 2 * sizeof(void*));
char prev_fill = out->fill('0');
*out << static_cast<void*>(h) << std::left;
out->fill(prev_fill);
*out << " " << std::left << data.str() << std::endl;
}

static void WriteNodeReport(Isolate* isolate, DumpEvent event, const char* message, const char* location, char* filename, std::ostream &out, TIME_TYPE* tm_struct) {
Expand All @@ -704,6 +706,10 @@ static void WriteNodeReport(Isolate* isolate, DumpEvent event, const char* messa
pid_t pid = getpid();
#endif

// Save formatting for output stream.
std::ios oldState(nullptr);
oldState.copyfmt(out);

// File stream opened OK, now start printing the report content, starting with the title
// and header information (event, filename, timestamp and pid)
out << "================================================================================\n";
Expand Down Expand Up @@ -779,6 +785,9 @@ static void WriteNodeReport(Isolate* isolate, DumpEvent event, const char* messa
out << "\n================================================================================\n";
out << std::flush;

// Restore output stream formatting.
out.copyfmt(oldState);

report_active = false;
}

Expand Down

0 comments on commit d3b8a03

Please sign in to comment.