| 1 |
/***************************************************************************
|
| 2 |
log.c - description
|
| 3 |
-------------------
|
| 4 |
begin : Mon Oct 18 2004
|
| 5 |
copyright : (C) 2004 by leaf
|
| 6 |
email : leaflet@leafok.com
|
| 7 |
***************************************************************************/
|
| 8 |
|
| 9 |
/***************************************************************************
|
| 10 |
* *
|
| 11 |
* This program is free software; you can redistribute it and/or modify *
|
| 12 |
* it under the terms of the GNU General Public License as published by *
|
| 13 |
* the Free Software Foundation; either version 2 of the License, or *
|
| 14 |
* (at your option) any later version. *
|
| 15 |
* *
|
| 16 |
***************************************************************************/
|
| 17 |
|
| 18 |
#include "common.h"
|
| 19 |
|
| 20 |
FILE *fp_log_std;
|
| 21 |
FILE *fp_log_err;
|
| 22 |
|
| 23 |
int
|
| 24 |
log_begin (char *file_log_std, char *file_log_err)
|
| 25 |
{
|
| 26 |
fp_log_std = fopen (file_log_std, "a");
|
| 27 |
if (fp_log_std == NULL)
|
| 28 |
{
|
| 29 |
perror ("log_begin failed\n");
|
| 30 |
return -1;
|
| 31 |
}
|
| 32 |
|
| 33 |
fp_log_err = fopen (file_log_err, "a");
|
| 34 |
if (fp_log_err == NULL)
|
| 35 |
{
|
| 36 |
perror ("log_begin failed\n");
|
| 37 |
return -1;
|
| 38 |
}
|
| 39 |
|
| 40 |
return 0;
|
| 41 |
}
|
| 42 |
|
| 43 |
int
|
| 44 |
log_end ()
|
| 45 |
{
|
| 46 |
fclose (fp_log_std);
|
| 47 |
fclose (fp_log_err);
|
| 48 |
}
|
| 49 |
|
| 50 |
int
|
| 51 |
log_std (char *msg)
|
| 52 |
{
|
| 53 |
if (fp_log_std == NULL)
|
| 54 |
{
|
| 55 |
perror ("log_std failed\n");
|
| 56 |
return -1;
|
| 57 |
}
|
| 58 |
|
| 59 |
if (fprintf (fp_log_std, msg)<0)
|
| 60 |
{
|
| 61 |
perror ("log_std failed\n");
|
| 62 |
return -2;
|
| 63 |
}
|
| 64 |
|
| 65 |
return 0;
|
| 66 |
}
|
| 67 |
|
| 68 |
int
|
| 69 |
log_error (char *error_msg)
|
| 70 |
{
|
| 71 |
if (fp_log_err == NULL)
|
| 72 |
{
|
| 73 |
perror ("log_error failed\n");
|
| 74 |
return -1;
|
| 75 |
}
|
| 76 |
|
| 77 |
if (fprintf (fp_log_err, error_msg)<0)
|
| 78 |
{
|
| 79 |
perror ("log_error failed\n");
|
| 80 |
return -2;
|
| 81 |
}
|
| 82 |
|
| 83 |
return 0;
|
| 84 |
}
|