message: Implements requested change.
diff: @@ -161,6 +161,42 @@ void TFLogSinks::SendToSink(TFLogSink& sink, const TFLogEntry& entry) {
  sink.WaitTillSent();
  }
  +// A class for managing the text file to which VLOG output is written.
  +// If the environment variable TF_CPP_VLOG_FILENAME is set, all VLOG
  +// calls are redirected from stderr to a file with corresponding name.
  +class VlogFileMgr {
  + public:
  + // Determines if the env variable is set and if necessary
  + // opens the file for write access.
  + VlogFileMgr();
  + // Closes the file.
  + ~VlogFileMgr();
  + // Returns either a pointer to the file or stderr.
  + FILE* FilePtr() const;
  +
  + private:
  + FILE* vlog_file_ptr;
  + char* vlog_file_name;
  +};
  +
  +VlogFileMgr::VlogFileMgr() {
  + vlog_file_name = getenv("TF_CPP_VLOG_FILENAME");
  + vlog_file_ptr =
  + vlog_file_name == nullptr ? nullptr : fopen(vlog_file_name, "w");
  +
  + if (vlog_file_ptr == nullptr) {
  + vlog_file_ptr = stderr;
  + }
  +}
  +
  +VlogFileMgr::~VlogFileMgr() {
  + if (vlog_file_ptr != stderr) {
  + fclose(vlog_file_ptr);
  + }
  +}
  +
  +FILE* VlogFileMgr::FilePtr() const { return vlog_file_ptr; }
  +
  int ParseInteger(const char* str, size_t size) {
  // Ideally we would use env_var / safe_strto64, but it is
  // hard to use here without pulling in a lot of dependencies,
  @@ -286,42 +322,6 @@ int64 MaxVLogLevelFromEnv() {
  #endif
  }
  -// A class for managing the text file to which VLOG output is written.
  -// If the environment variable TF_CPP_VLOG_FILENAME is set, all VLOG
  -// calls are redirected from stderr to a file with corresponding name.
  -class VlogFileMgr {
  - public:
  - // Determines if the env variable is set and if necessary
  - // opens the file for write access.
  - VlogFileMgr();
  - // Closes the file.
  - ~VlogFileMgr();
  - // Returns either a pointer to the file or stderr.
  - FILE* FilePtr() const;
  -
  - private:
  - FILE* vlog_file_ptr;
  - char* vlog_file_name;
  -};
  -
  -VlogFileMgr::VlogFileMgr() {
  - vlog_file_name = getenv("TF_CPP_VLOG_FILENAME");
  - vlog_file_ptr =
  - vlog_file_name == nullptr ? nullptr : fopen(vlog_file_name, "w");
  -
  - if (vlog_file_ptr == nullptr) {
  - vlog_file_ptr = stderr;
  - }
  -}
  -
  -VlogFileMgr::~VlogFileMgr() {
  - if (vlog_file_ptr != stderr) {
  - fclose(vlog_file_ptr);
  - }
  -}
  -
  -FILE* VlogFileMgr::FilePtr() const { return vlog_file_ptr; }
  -
  LogMessage::LogMessage(const char* fname, int line, int severity)
  : fname_(fname), line_(line), severity_(severity) {}
  