| 81 | max_log_files_(max_log_files) {} |
| 82 | |
| 83 | Status SimpleLogger::Init() { |
| 84 | // Check that Init hasn't already been called by verifying the log_file_name_ is still |
| 85 | // empty. |
| 86 | DCHECK(!initialized_); |
| 87 | DCHECK(log_file_name_.empty()); |
| 88 | RETURN_IF_ERROR(InitLoggingDir(log_dir_)); |
| 89 | log_file_name_ = GenerateLogFileName(); |
| 90 | RETURN_IF_ERROR(FlushInternal()); |
| 91 | LOG(INFO) << "Logging to: " << log_file_name_; |
| 92 | // There may be preexisting files from a previous incarnation of this logger. For |
| 93 | // example, if a service restarted and logged in the same locations. Proactively |
| 94 | // enforce the limit on the number of files to keep the semantics clear. |
| 95 | RotateLogFiles(); |
| 96 | initialized_ = true; |
| 97 | return Status::OK(); |
| 98 | } |
| 99 | |
| 100 | Status SimpleLogger::AppendEntry(const std::string& entry) { |
| 101 | DCHECK(initialized_); |
nothing calls this directly
no test coverage detected