| 15 |
* * |
* * |
| 16 |
***************************************************************************/ |
***************************************************************************/ |
| 17 |
|
|
| 18 |
#include "common.h" |
#include "io.h" |
| 19 |
|
#include <stdio.h> |
| 20 |
|
#include <stdarg.h> |
| 21 |
|
#include <time.h> |
| 22 |
|
|
| 23 |
FILE *fp_log_std; |
FILE *fp_log_std; |
| 24 |
FILE *fp_log_err; |
FILE *fp_log_err; |
| 64 |
} |
} |
| 65 |
|
|
| 66 |
int |
int |
| 67 |
log_std (char *msg) |
log_std(const char * format, ...) |
| 68 |
{ |
{ |
| 69 |
|
va_list args; |
| 70 |
|
int retval; |
| 71 |
char buf[1024]; |
char buf[1024]; |
| 72 |
|
|
|
if (fp_log_std == NULL) |
|
|
{ |
|
|
perror ("log_std failed\n"); |
|
|
return -1; |
|
|
} |
|
|
|
|
| 73 |
log_head(buf); |
log_head(buf); |
| 74 |
|
strcat(buf, format); |
| 75 |
|
|
| 76 |
strcat(buf,msg); |
va_start (args, format); |
| 77 |
|
retval = vfprintf (fp_log_std, buf, args); |
| 78 |
if (fprintf (fp_log_std, buf)<0) |
va_end (args); |
|
{ |
|
|
perror ("log_std failed\n"); |
|
|
return -2; |
|
|
} |
|
| 79 |
|
|
| 80 |
fflush(fp_log_std); |
fflush(fp_log_std); |
| 81 |
|
|
| 82 |
return 0; |
return retval; |
| 83 |
} |
} |
| 84 |
|
|
| 85 |
int |
int |
| 86 |
log_error (char *error_msg) |
log_error (const char * format, ...) |
| 87 |
{ |
{ |
| 88 |
|
va_list args; |
| 89 |
|
int retval; |
| 90 |
char buf[1024]; |
char buf[1024]; |
|
|
|
|
if (fp_log_err == NULL) |
|
|
{ |
|
|
perror ("log_error failed\n"); |
|
|
return -1; |
|
|
} |
|
| 91 |
|
|
| 92 |
log_head(buf); |
log_head(buf); |
| 93 |
|
strcat(buf, format); |
| 94 |
|
|
| 95 |
strcat(buf,error_msg); |
va_start (args, format); |
| 96 |
|
retval = vfprintf (fp_log_err, buf, args); |
| 97 |
|
va_end (args); |
| 98 |
|
|
|
if (fprintf (fp_log_err, buf)<0) |
|
|
{ |
|
|
perror ("log_error failed\n"); |
|
|
return -2; |
|
|
} |
|
|
|
|
| 99 |
fflush(fp_log_err); |
fflush(fp_log_err); |
| 100 |
|
|
| 101 |
return 0; |
return retval; |
| 102 |
} |
} |
| 103 |
|
|
| 104 |
int |
int |