log: cleanup: avoid "magic" numbers

We used a bare '15' in several places and it's not immediately
obvious where it came from.  This makes it more obvious

git-svn-id: https://svn.musicpd.org/mpd/trunk@6829 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Eric Wong 2007-08-28 05:01:16 +00:00
parent 1b045d0672
commit cd6e584c35

View File

@ -28,6 +28,8 @@
#include <stdarg.h>
#include <time.h>
#define LOG_DATE_BUF_SIZE 16
#define LOG_DATE_LEN (LOG_DATE_BUF_SIZE - 1)
static unsigned int logLevel = LOG_LEVEL_LOW;
static int warningFlushed;
static int stdout_mode = 1;
@ -59,9 +61,9 @@ static void redirect_logs(void)
static const char *log_date(void)
{
static char buf[16];
static char buf[LOG_DATE_BUF_SIZE];
time_t t = time(NULL);
strftime(buf, 16, "%b %d %H:%M : ", localtime(&t));
strftime(buf, LOG_DATE_BUF_SIZE, "%b %d %H:%M : ", localtime(&t));
return buf;
}
@ -73,9 +75,9 @@ static void buffer_warning(const char *fmt, va_list args)
size_t len = BUFFER_LENGTH;
if (!stdout_mode) {
memcpy(buffer, log_date(), 15);
tmp += 15;
len -= 15;
memcpy(buffer, log_date(), LOG_DATE_LEN);
tmp += LOG_DATE_LEN;
len -= LOG_DATE_LEN;
}
vsnprintf(tmp, len, fmt, args);
@ -87,7 +89,7 @@ static void buffer_warning(const char *fmt, va_list args)
static void do_log(FILE *fp, const char *fmt, va_list args)
{
if (!stdout_mode)
fwrite(log_date(), 15, 1, fp);
fwrite(log_date(), LOG_DATE_LEN, 1, fp);
vfprintf(fp, fmt, args);
}