| 41 | namespace internal { |
| 42 | |
| 43 | class LogMessage : public std::basic_ostringstream<char> { |
| 44 | public: |
| 45 | LogMessage(const char* fname, int line, int severity); |
| 46 | ~LogMessage(); |
| 47 | |
| 48 | // Change the location of the log message. |
| 49 | LogMessage& AtLocation(const char* fname, int line); |
| 50 | |
| 51 | // Returns the minimum log level for VLOG statements. |
| 52 | // E.g., if MinVLogLevel() is 2, then VLOG(2) statements will produce output, |
| 53 | // but VLOG(3) will not. Defaults to 0. |
| 54 | static int64 MinVLogLevel(); |
| 55 | |
| 56 | // Returns whether VLOG level lvl is activated for the file fname. |
| 57 | // |
| 58 | // E.g. if the environment variable TF_CPP_VMODULE contains foo=3 and fname is |
| 59 | // foo.cc and lvl is <= 3, this will return true. It will also return true if |
| 60 | // the level is lower or equal to TF_CPP_MIN_VLOG_LEVEL (default zero). |
| 61 | // |
| 62 | // It is expected that the result of this query will be cached in the VLOG-ing |
| 63 | // call site to avoid repeated lookups. This routine performs a hash-map |
| 64 | // access against the VLOG-ing specification provided by the env var. |
| 65 | static bool VmoduleActivated(const char* fname, int level); |
| 66 | |
| 67 | protected: |
| 68 | void GenerateLogMessage(); |
| 69 | |
| 70 | private: |
| 71 | const char* fname_; |
| 72 | int line_; |
| 73 | int severity_; |
| 74 | }; |
| 75 | |
| 76 | // Uses the lower operator & precedence to voidify a LogMessage reference, so |
| 77 | // that the ternary VLOG() implementation is balanced, type wise. |