| 48 | |
| 49 | |
| 50 | bool init() { |
| 51 | if (outputFile) |
| 52 | return true; |
| 53 | |
| 54 | std::lock_guard<std::mutex> lock(mutex); |
| 55 | truncated = false; |
| 56 | |
| 57 | // Don't open a file in development mode. |
| 58 | if (logPath.empty()) { |
| 59 | outputFile = stderr; |
| 60 | } |
| 61 | else { |
| 62 | truncated = isTruncated(); |
| 63 | |
| 64 | outputFile = std::fopen(logPath.c_str(), "w"); |
| 65 | if (!outputFile) { |
| 66 | std::fprintf(stderr, "Could not open log at %s\n", logPath.c_str()); |
| 67 | return false; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | void destroy() { |
| 75 | std::lock_guard<std::mutex> lock(mutex); |
nothing calls this directly
no test coverage detected