| 145 | } |
| 146 | |
| 147 | void LogManager::_flush() |
| 148 | { |
| 149 | /*-------------------------------------------------*\ |
| 150 | | If the log is open, write out buffered messages | |
| 151 | \*-------------------------------------------------*/ |
| 152 | if(log_stream.is_open()) |
| 153 | { |
| 154 | for(size_t msg = 0; msg < temp_messages.size(); ++msg) |
| 155 | { |
| 156 | if(temp_messages[msg]->level <= loglevel || temp_messages[msg]->level == LL_DIALOG) |
| 157 | { |
| 158 | // Put the timestamp here |
| 159 | std::chrono::milliseconds counter = std::chrono::duration_cast<std::chrono::milliseconds>(temp_messages[msg]->counted_second); |
| 160 | log_stream << std::left << std::setw(6) << counter.count() << "|"; |
| 161 | log_stream << std::left << std::setw(9) << log_codes[temp_messages[msg]->level]; |
| 162 | log_stream << temp_messages[msg]->buffer; |
| 163 | |
| 164 | if(print_source) |
| 165 | { |
| 166 | log_stream << " [" << temp_messages[msg]->filename << ":" << temp_messages[msg]->line << "]"; |
| 167 | } |
| 168 | |
| 169 | log_stream << std::endl; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /*-------------------------------------------------*\ |
| 174 | | Clear temp message buffers after writing them out | |
| 175 | \*-------------------------------------------------*/ |
| 176 | temp_messages.clear(); |
| 177 | } |
| 178 | |
| 179 | /*-------------------------------------------------*\ |
| 180 | | Flush the stream | |
| 181 | \*-------------------------------------------------*/ |
| 182 | log_stream.flush(); |
| 183 | } |
| 184 | |
| 185 | void LogManager::flush() |
| 186 | { |