log: prefix dump with line numbers

This makes it easier to interpret the dump, and makes it obvious what is
dump (and potentially a dup of something that was already logged) and what
is not.

Signed-off-by: Sage Weil <sage@newdream.net>
This commit is contained in:
Sage Weil 2012-04-20 16:36:54 -07:00
parent a68b3069de
commit f7699cc993

View File

@ -185,8 +185,12 @@ void Log::_flush(EntryQueue *t, EntryQueue *requeue, bool crash)
bool do_stderr = (crash ? m_stderr_crash : m_stderr_log) >= e->m_prio;
if (do_fd || do_syslog || do_stderr) {
int buflen = e->m_stamp.sprintf(buf, sizeof(buf));
buflen += sprintf(buf + buflen, " %lx %2d ",
int buflen = 0;
if (crash)
buflen += snprintf(buf, sizeof(buf), "%6d> ", -t->m_len);
buflen += e->m_stamp.sprintf(buf + buflen, sizeof(buf)-buflen);
buflen += snprintf(buf + buflen, sizeof(buf)-buflen, " %lx %2d ",
(unsigned long)e->m_thread, e->m_prio);
// FIXME: this is slow