--- lbbs/src/log.c 2004/10/18 11:33:20 1.1 +++ lbbs/src/log.c 2004/10/19 02:08:35 1.2 @@ -48,37 +48,64 @@ log_end () } int +log_head (char *buf) +{ + time_t t; + char s_time[256]; + t = time(0); + + strftime(s_time,256,"%Y-%m-%d %H:%M:%S", localtime (&t)); + sprintf(buf,"[%s] [%d] ", s_time, getpid()); + + return 0; +} + +int log_std (char *msg) { + char buf[1024]; + if (fp_log_std == NULL) { perror ("log_std failed\n"); return -1; } - if (fprintf (fp_log_std, msg)<0) + log_head(buf); + strcat(buf,msg); + + if (fprintf (fp_log_std, buf)<0) { perror ("log_std failed\n"); return -2; } + fflush(fp_log_std); + return 0; } int log_error (char *error_msg) { + char buf[1024]; + if (fp_log_err == NULL) { perror ("log_error failed\n"); return -1; } - if (fprintf (fp_log_err, error_msg)<0) + log_head(buf); + strcat(buf,error_msg); + + if (fprintf (fp_log_err, buf)<0) { perror ("log_error failed\n"); return -2; } + + fflush(fp_log_err); return 0; }