| 150 | } |
| 151 | |
| 152 | static void Log(const std::string& str, bool fatal) { |
| 153 | if (fatal) Limit() = 0; |
| 154 | |
| 155 | FILE* output = File(); |
| 156 | if (output) { |
| 157 | fwrite(str.data(), sizeof(char), str.size(), output); |
| 158 | fflush(output); |
| 159 | |
| 160 | if (Limit() && !isatty(fileno(output))) { |
| 161 | if (lseek(fileno(output), 0, SEEK_END) > Limit()) { |
| 162 | fclose(output), File(""); |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | if (fatal && !isatty(fileno(output))) { |
| 168 | fputs(str.c_str(), stderr); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | friend class Logger<LOG>; |
| 173 | }; |