Fix DEBUG_packet_visualise() log output

This commit is contained in:
Andrew Bettison 2012-08-03 13:12:54 +09:30
parent 355af1f874
commit 9ede55ab4c
3 changed files with 7 additions and 4 deletions

4
log.c
View File

@ -223,14 +223,14 @@ void logString(int level, const char *file, unsigned int line, const char *funct
for (p = str; *p; ++p) {
if (*p == '\n') {
if (_log_prepare(level, file, line, function)) {
strbuf_ncat(&logbuf, str, p - s);
strbuf_ncat(&logbuf, s, p - s);
_log_finish(level);
}
s = p + 1;
}
}
if (p > s && _log_prepare(level, file, line, function)) {
strbuf_ncat(&logbuf, str, p - s);
strbuf_ncat(&logbuf, s, p - s);
_log_finish(level);
}
}

1
log.h
View File

@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define __SERVALD_LOG_H
#include <stdio.h>
#include <stdarg.h>
extern unsigned int debug;

View File

@ -1032,8 +1032,8 @@ long long parse_quantity(char *q)
void logServalPacket(int level, const char *file, unsigned int line, const char *function, const char *message, const unsigned char *packet, size_t len)
{
char *buffer;
size_t size;
char *buffer = NULL;
size_t size = 0;
FILE *m = open_memstream(&buffer, &size);
if (m == NULL) {
WHY_perror("open_memstream");
@ -1045,4 +1045,6 @@ void logServalPacket(int level, const char *file, unsigned int line, const char
WHY_perror("fclose");
else
logString(level, file, line, function, buffer);
if (buffer)
free(buffer);
}