/[imapfilter]/imapfilter/log.c
ViewVC logotype

Diff of /imapfilter/log.c

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

revision 1.9 by lefcha, Tue Aug 28 22:44:28 2001 UTC revision 1.10 by lefcha, Mon Sep 10 23:43:29 2001 UTC
# Line 11  Line 11 
11    
12  #include "config.h"  #include "config.h"
13  #include "imapfilter.h"  #include "imapfilter.h"
 #include "log.h"  
14    
15    
16  extern char logfile[PATH_MAX];  extern char logfile[PATH_MAX];
17  extern unsigned int options;  extern unsigned int options;
18    
19  static FILE *logfp = NULL;      /* Points to logfile. */  static FILE *logfp = NULL;      /* Pointer to logfile. */
20    
21    
22  /*  /*
23   * Prints message if not in OPT_DETAILS_QUITE mode.   * Prints message if not in OPTION_DETAILS_QUITE mode.
24   */   */
25  void info(const char *info, ...)  void info(const char *info, ...)
26  {  {
27      va_list args;      va_list args;
28    
29      if (!(options & OPT_DETAILS_QUITE)) {      if (!(options & OPTION_DETAILS_QUITE)) {
30          va_start(args, info);          va_start(args, info);
31          vprintf(info, args);          vprintf(info, args);
32          va_end(args);          va_end(args);
# Line 36  void info(const char *info, ...) Line 35  void info(const char *info, ...)
35    
36    
37  /*  /*
38   * Prints message if in OPT_DETAILS_VERBOSE mode.   * Print message if in OPTION_DETAILS_VERBOSE mode.
39   */   */
40  void verbose(const char *info, ...)  void verbose(const char *info, ...)
41  {  {
42      va_list args;      va_list args;
43    
44      if (options & OPT_DETAILS_VERBOSE) {      if (options & OPTION_DETAILS_VERBOSE) {
45          va_start(args, info);          va_start(args, info);
46          vprintf(info, args);          vprintf(info, args);
47          va_end(args);          va_end(args);
# Line 50  void verbose(const char *info, ...) Line 49  void verbose(const char *info, ...)
49  }  }
50    
51  /*  /*
52   * Prints error message and writes it into logfile.   * Print error message and write it into logfile.
53   */   */
54  void error(const char *errmsg, ...)  void error(const char *errmsg, ...)
55  {  {
# Line 63  void error(const char *errmsg, ...) Line 62  void error(const char *errmsg, ...)
62      }      }
63    
64      vfprintf(stderr, errmsg, args);      vfprintf(stderr, errmsg, args);
65    
66      va_end(args);      va_end(args);
67  }  }
68    
69    
70  /*  /*
71   * Opens the file to save logging information.   * Open the file to save logging information.
72   */   */
73  int open_logfile(void)  int open_logfile(void)
74  {  {
75      if (!(logfile[0]))      if (!*logfile)
76          return 0;               /* Logging not enabled. */          return 0;               /* Logging not enabled. */
77    
78  #ifdef DEBUG  #ifdef DEBUG
# Line 95  int open_logfile(void) Line 95  int open_logfile(void)
95    
96    
97  /*  /*
98   *   * If file does not exist, create it with proper permissions.
99   */   */
100  int create_logfile(void)  int create_logfile(void)
101  {  {
# Line 118  int create_logfile(void) Line 118  int create_logfile(void)
118    
119    
120  /*  /*
121   * Closes the logfile.   * Close the logfile.
122   */   */
123  int close_logfile(void)  int close_logfile(void)
124  {  {
# Line 130  int close_logfile(void) Line 130  int close_logfile(void)
130    
131    
132  /*  /*
133   * Writes information to logfile.   * Write information to logfile.
134   */   */
135  void log_info(const char *info, ...)  void log_info(const char *info, ...)
136  {  {
137      va_list args;      va_list args;
138    
139        va_start(args, info);
140    
141      if (logfp) {      if (logfp) {
         va_start(args, info);  
142          vfprintf(logfp, info, args);          vfprintf(logfp, info, args);
         va_end(args);  
143      }      }
144    
145        vfprintf(stdout, info, args);
146    
147        va_end(args);
148  }  }

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26