使用以下代码替换log函数:
static void redisLog(int level, const char *fmt, ...) {
va_list ap;
FILE *fp;
char *c = ".-*#";
char buf[64];
time_t now;
struct tm *tm;
char log_path[1024];
if (level < server.verbosity) return;
sprintf(log_path, "squirrel_%d%d.log", tm->tm_year + 1900, tm->tm_mon + 1);
//fp = (server.logfile == NULL) ? stdout : fopen(server.logfile,"a");
fp = fopen(log_path, "a");
if (!fp) return;
va_start(ap, fmt);
now = time(NULL);
strftime(buf,64,"%d %b %H:%M:%S",localtime(&now));
fprintf(fp,"[%d] %s %c ",(int)getpid(),buf,c[level]);
vfprintf(fp, fmt, ap);
fprintf(fp,"\n");
fflush(fp);
va_end(ap);
if (server.logfile) fclose(fp);
}