]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/log/Log.cc
update sources to 12.2.7
[ceph.git] / ceph / src / log / Log.cc
index bf219d379fadf4c5f5e1dc80ad052328d12844c4..5f7e23b4b048c0343972e53355463a864ea2a108 100644 (file)
@@ -126,6 +126,11 @@ void Log::set_log_file(string fn)
   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);
@@ -275,7 +280,7 @@ void Log::flush()
 
   // trim
   while (m_recent.m_len > m_max_recent) {
-    delete m_recent.dequeue();
+    m_recent.dequeue()->destroy();
   }
 
   m_flush_mutex_holder = 0;
@@ -327,7 +332,7 @@ void Log::_flush(EntryQueue *t, EntryQueue *requeue, bool crash)
       }
 
       if (do_stderr) {
-        cerr << buf << std::endl;
+        cerr << m_log_stderr_prefix << buf << std::endl;
       }
       if (do_fd) {
         buf[buflen] = '\n';
@@ -428,13 +433,14 @@ void Log::start()
 
 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()