tvhlog: fix some problems with hexdump code
This commit is contained in:
parent
f442a28b77
commit
99fe1c73a7
2 changed files with 10 additions and 8 deletions
14
src/tvhlog.c
14
src/tvhlog.c
|
@ -114,7 +114,7 @@ next:
|
|||
/* Log */
|
||||
void tvhlogv ( const char *file, int line,
|
||||
int notify, int severity,
|
||||
const char *subsys, const char *fmt, va_list args )
|
||||
const char *subsys, const char *fmt, va_list args, int noargs )
|
||||
{
|
||||
struct timeval now;
|
||||
struct tm tm;
|
||||
|
@ -166,7 +166,10 @@ void tvhlogv ( const char *file, int line,
|
|||
l = snprintf(buf, sizeof(buf), "%s: ", subsys);
|
||||
if (options & TVHLOG_OPT_FILELINE && severity >= LOG_DEBUG)
|
||||
l += snprintf(buf + l, sizeof(buf) - l, "(%s:%d) ", file, line);
|
||||
l += vsnprintf(buf + l, sizeof(buf) - l, fmt, args);
|
||||
if (noargs)
|
||||
l += snprintf(buf + l, sizeof(buf) - l, "%s", fmt);
|
||||
else
|
||||
l += vsnprintf(buf + l, sizeof(buf) - l, fmt, args);
|
||||
|
||||
/* Syslog */
|
||||
if (options & TVHLOG_OPT_SYSLOG) {
|
||||
|
@ -226,7 +229,7 @@ void _tvhlog ( const char *file, int line,
|
|||
va_list args;
|
||||
//pthread_mutex_lock(&tvhlog_mutex);
|
||||
va_start(args, fmt);
|
||||
tvhlogv(file, line, notify, severity, subsys, fmt, args);
|
||||
tvhlogv(file, line, notify, severity, subsys, fmt, args, 0);
|
||||
va_end(args);
|
||||
//pthread_mutex_unlock(&tvhlog_mutex);
|
||||
}
|
||||
|
@ -239,12 +242,11 @@ void
|
|||
_tvhlog_hexdump(const char *file, int line,
|
||||
int notify, int severity,
|
||||
const char *subsys,
|
||||
const uint8_t *data, ssize_t len, ...)
|
||||
const uint8_t *data, ssize_t len )
|
||||
{
|
||||
int i, c;
|
||||
char str[1024];
|
||||
va_list args;
|
||||
va_start(args, len);
|
||||
|
||||
//pthread_mutex_lock(&tvhlog_mutex);
|
||||
while (len > 0) {
|
||||
|
@ -266,7 +268,7 @@ _tvhlog_hexdump(const char *file, int line,
|
|||
c++;
|
||||
}
|
||||
str[c] = '\0';
|
||||
tvhlogv(file, line, notify, severity, subsys, str, args);
|
||||
tvhlogv(file, line, notify, severity, subsys, str, args, 1);
|
||||
len -= HEXDUMP_WIDTH;
|
||||
data += HEXDUMP_WIDTH;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ void tvhlog_set_subsys ( const char *subsys );
|
|||
void tvhlog_get_subsys ( char *subsys, size_t len );
|
||||
void tvhlogv ( const char *file, int line,
|
||||
int notify, int severity,
|
||||
const char *subsys, const char *fmt, va_list args );
|
||||
const char *subsys, const char *fmt, va_list args, int noargs );
|
||||
void _tvhlog ( const char *file, int line,
|
||||
int notify, int severity,
|
||||
const char *subsys, const char *fmt, ... )
|
||||
|
@ -45,7 +45,7 @@ void _tvhlog ( const char *file, int line,
|
|||
void _tvhlog_hexdump ( const char *file, int line,
|
||||
int notify, int severity,
|
||||
const char *subsys,
|
||||
const uint8_t *data, ssize_t len, ... );
|
||||
const uint8_t *data, ssize_t len );
|
||||
|
||||
|
||||
/* Options */
|
||||
|
|
Loading…
Add table
Reference in a new issue