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

Diff of /monit/log.c

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

revision 1.12 by hauk, Fri Jun 6 16:43:06 2003 UTC revision 1.13 by hauk, Thu Jun 26 14:24:11 2003 UTC
# Line 65  Line 65 
65   */   */
66    
67    
68  /* ------------------------------------------------------- Private variables */  /* ------------------------------------------------------------- Definitions */
69    
70    
71    #define MESSAGE_SIZE 1024
72  static FILE *LOG= NULL;  static FILE *LOG= NULL;
73  static char time_str[STRLEN];  static char time_str[STRLEN];
74    
# Line 110  int log_init() { Line 111  int log_init() {
111    
112    
113  /**  /**
114   * Log a message to monits logfile or syslog   * Log a message to monits logfile or syslog. If a TTY exist the log
115     * message is also sent to stderr.
116   * @param format A formated (printf-style) string to log   * @param format A formated (printf-style) string to log
117   */   */
118  void log_log(const char *format, ...) {  void log_log(const char *format, ...) {
119        
120    va_list ap;    va_list ap;
121    char msg[STRLEN];    char msg[MESSAGE_SIZE];
122    
123    ASSERT(format);    ASSERT(format);
124        
125    va_start(ap,format);    va_start(ap,format);
126    vsnprintf(msg, STRLEN, format, ap);    vsnprintf(msg, MESSAGE_SIZE, format, ap);
127    va_end(ap);    va_end(ap);
128    
129    if(! Run.dolog) goto nolog;    if(! Run.dolog) goto nolog;
# Line 160  void log_close() { Line 162  void log_close() {
162        
163    if(LOG  && (0 != fclose(LOG))) {    if(LOG  && (0 != fclose(LOG))) {
164            
165      error("%s: Error closing the log file -- %s\n",      log("%s: Error closing the log file -- %s\n",
166            prog, STRERROR);            prog, STRERROR);
167            
168    }    }
# Line 188  static int open_log() { Line 190  static int open_log() {
190            
191      if((LOG= fopen(Run.logfile,"a+")) == (FILE *)NULL) {      if((LOG= fopen(Run.logfile,"a+")) == (FILE *)NULL) {
192                
193        error("%s: Error opening the log file '%s' for writing -- %s\n",        log("%s: Error opening the log file '%s' for writing -- %s\n",
194              prog, Run.logfile, STRERROR);              prog, Run.logfile, STRERROR);
195                
196        return(FALSE);        return(FALSE);

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26