/[LeafOK_CVS]/lbbs/src/log.c
ViewVC logotype

Diff of /lbbs/src/log.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.8 by sysadm, Sun Mar 20 14:37:37 2005 UTC Revision 1.9 by sysadm, Sun Mar 20 17:37:14 2005 UTC
# Line 55  log_head (char *buf) Line 55  log_head (char *buf)
55  {  {
56    time_t t;    time_t t;
57    char s_time[256];    char s_time[256];
58    t = time(0);    t = time (0);
59      
60    strftime(s_time,256,"%Y-%m-%d %H:%M:%S", localtime (&t));    strftime (s_time, 256, "%Y-%m-%d %H:%M:%S", localtime (&t));
61    sprintf(buf,"[%s] [%d] ", s_time, getpid ());    sprintf (buf, "[%s] [%d] ", s_time, getpid ());
62      
63    return 0;    return 0;
64  }  }
65    
66  int  int
67  log_std(const char * format, ...)  log_std (const char *format, ...)
68  {  {
69    va_list args;    va_list args;
70    int retval;    int retval;
71    char buf[1024];    char buf[1024];
72    
73    log_head(buf);    log_head (buf);
74    strcat(buf, format);    strcat (buf, format);
75    
76    va_start (args, format);    va_start (args, format);
77    retval = vfprintf (fp_log_std, buf, args);    retval = vfprintf (fp_log_std, buf, args);
78    va_end (args);    va_end (args);
79    
80    fflush(fp_log_std);    fflush (fp_log_std);
81    
82    return retval;    return retval;
83  }  }
84    
85  int  int
86  log_error (const char * format, ...)  log_error (const char *format, ...)
87  {  {
88    va_list args;    va_list args;
89    int retval;    int retval;
90    char buf[1024];    char buf[1024];
91    
92    log_head(buf);    log_head (buf);
93    strcat(buf, format);    strcat (buf, format);
94    
95    va_start (args, format);    va_start (args, format);
96    retval = vfprintf (fp_log_err, buf, args);    retval = vfprintf (fp_log_err, buf, args);
97    va_end (args);    va_end (args);
98    
99    fflush(fp_log_err);    fflush (fp_log_err);
100    
101    return retval;    return retval;
102  }  }
103    
104  int  int
105  log_std_redirect(int fd)  log_std_redirect (int fd)
106  {  {
107    int ret;    int ret;
108    close (fileno(fp_log_std));    close (fileno (fp_log_std));
109    ret =  dup2(fd, fileno(fp_log_std));    ret = dup2 (fd, fileno (fp_log_std));
110    return ret;    return ret;
111  }  }
112    
113  int  int
114  log_err_redirect(int fd)  log_err_redirect (int fd)
115  {  {
116    int ret;    int ret;
117    close (fileno(fp_log_err));    close (fileno (fp_log_err));
118    ret =  dup2(fd, fileno(fp_log_err));    ret = dup2 (fd, fileno (fp_log_err));
119    return ret;    return ret;
120  }  }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1