m_log_file = fn;
}
+void Log::set_log_stderr_prefix(const std::string& p)
+{
+ m_log_stderr_prefix = p;
+}
+
void Log::reopen_log_file()
{
pthread_mutex_lock(&m_flush_mutex);
// trim
while (m_recent.m_len > m_max_recent) {
- delete m_recent.dequeue();
+ m_recent.dequeue()->destroy();
}
m_flush_mutex_holder = 0;
}
if (do_stderr) {
- cerr << buf << std::endl;
+ cerr << m_log_stderr_prefix << buf << std::endl;
}
if (do_fd) {
buf[buflen] = '\n';
void Log::stop()
{
- assert(is_started());
- pthread_mutex_lock(&m_queue_mutex);
- m_stop = true;
- pthread_cond_signal(&m_cond_flusher);
- pthread_cond_broadcast(&m_cond_loggers);
- pthread_mutex_unlock(&m_queue_mutex);
- join();
+ if (is_started()) {
+ pthread_mutex_lock(&m_queue_mutex);
+ m_stop = true;
+ pthread_cond_signal(&m_cond_flusher);
+ pthread_cond_broadcast(&m_cond_loggers);
+ pthread_mutex_unlock(&m_queue_mutex);
+ join();
+ }
}
void *Log::entry()