Log the error at the given severity, optionally with a stack trace. If log_severity is NUM_SEVERITIES, nothing is logged.
| 39 | // Log the error at the given severity, optionally with a stack trace. |
| 40 | // If log_severity is NUM_SEVERITIES, nothing is logged. |
| 41 | static void LogError(const Status& status, const char* filename, int line, |
| 42 | int log_severity, bool should_log_stack_trace) { |
| 43 | if (TF_PREDICT_TRUE(log_severity != tensorflow::NUM_SEVERITIES)) { |
| 44 | string stack_trace; |
| 45 | if (should_log_stack_trace) { |
| 46 | stack_trace = absl::StrCat("\n", tensorflow::CurrentStackTrace()); |
| 47 | } |
| 48 | switch (log_severity) { |
| 49 | case tensorflow::INFO: |
| 50 | LOG(INFO) << status << stack_trace; |
| 51 | break; |
| 52 | case tensorflow::WARNING: |
| 53 | LOG(WARNING) << status << stack_trace; |
| 54 | break; |
| 55 | case tensorflow::ERROR: |
| 56 | LOG(ERROR) << status << stack_trace; |
| 57 | break; |
| 58 | case tensorflow::FATAL: |
| 59 | LOG(FATAL) << status << stack_trace; |
| 60 | break; |
| 61 | case tensorflow::NUM_SEVERITIES: |
| 62 | break; |
| 63 | default: |
| 64 | LOG(FATAL) << "Unknown LOG severity " << log_severity; |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | // Make a Status with a code, error message and payload, |
| 70 | // and also send it to LOG(<log_severity>) using the given filename |
no test coverage detected