Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/sbp.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ int _write(int file, char *ptr, int len)
}

/** Directs log_ output to the SBP log message */
void log_(u8 level, const char *msg, ...)
void log_(u8 level, const char *file, const int line, const char *msg, ...)
{
msg_log_t *log;
va_list ap;
Expand All @@ -344,7 +344,11 @@ void log_(u8 level, const char *msg, ...)
log->level = level;

va_start(ap, msg);
int n = vsnprintf(log->text, SBP_FRAMING_MAX_PAYLOAD_SIZE-sizeof(msg_log_t), msg, ap);
int n = snprintf(log->text, SBP_FRAMING_MAX_PAYLOAD_SIZE-sizeof(msg_log_t),
"(%s:%d) ", file, line);
va_start(ap, msg);
n += vsnprintf(&log->text[n], SBP_FRAMING_MAX_PAYLOAD_SIZE-sizeof(msg_log_t)-n,
msg, ap);
va_end(ap);

if (n < 0)
Expand Down