Show
Ignore:
Timestamp:
01/27/09 22:35:47 (5 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1233095747 +0000
git-parent:

[a5fda7af1c2eef671f02284031368b2908ca4998]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1233095747 +0000
Message:

update logging API to pass back errors, refs #73

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/utils/noit_log.c

    r87ce9be r7422acb  
    318318} 
    319319 
    320 static void 
     320static int 
    321321noit_log_line(noit_log_stream_t ls, char *buffer, size_t len) { 
     322  int rv = 0; 
    322323  struct _noit_log_stream_outlet_list *node; 
    323324  if(ls->ops) 
    324     ls->ops->writeop(ls, buffer, len); /* Not much one can do about errors */ 
     325    rv = ls->ops->writeop(ls, buffer, len); /* Not much one can do about errors */ 
    325326  for(node = ls->outlets; node; node = node->next) { 
    326     noit_log_line(node->outlet, buffer, len); 
    327   } 
    328 
    329 void 
     327    int srv = 0; 
     328    srv = noit_log_line(node->outlet, buffer, len); 
     329    if(srv) rv = srv; 
     330  } 
     331  return rv; 
     332
     333int 
    330334noit_vlog(noit_log_stream_t ls, struct timeval *now, 
    331335          const char *file, int line, 
    332336          const char *format, va_list arg) { 
    333   int allocd = 0; 
     337  int rv = 0, allocd = 0; 
    334338  char buffer[4096], *dynbuff = NULL; 
    335339#ifdef va_copy 
     
    361365#endif 
    362366      } 
    363       noit_log_line(ls, dynbuff, len); 
     367      rv = noit_log_line(ls, dynbuff, len); 
    364368      free(dynbuff); 
    365369    } 
    366370    else { 
    367       noit_log_line(ls, buffer, len); 
    368     } 
    369   } 
    370 
    371  
    372 void 
     371      rv = noit_log_line(ls, buffer, len); 
     372    } 
     373    if(rv == len) return 0; 
     374    return -1; 
     375  } 
     376  return 0; 
     377
     378 
     379int 
    373380noit_log(noit_log_stream_t ls, struct timeval *now, 
    374381         const char *file, int line, const char *format, ...) { 
     382  int rv; 
    375383  va_list arg; 
    376384  va_start(arg, format); 
    377   noit_vlog(ls, now, file, line, format, arg); 
     385  rv = noit_vlog(ls, now, file, line, format, arg); 
    378386  va_end(arg); 
    379 
    380  
     387  return rv; 
     388
     389 
  • src/utils/noit_log.h

    r4bed82b r7422acb  
    5858API_EXPORT(void) noit_log_stream_close(noit_log_stream_t ls); 
    5959API_EXPORT(void) noit_log_stream_free(noit_log_stream_t ls); 
    60 API_EXPORT(void) noit_vlog(noit_log_stream_t ls, struct timeval *, 
    61                            const char *file, int line, 
    62                            const char *format, va_list arg); 
    63 API_EXPORT(void) noit_log(noit_log_stream_t ls, struct timeval *, 
     60API_EXPORT(int) noit_vlog(noit_log_stream_t ls, struct timeval *, 
    6461                          const char *file, int line, 
    65                           const char *format, ...) 
     62                          const char *format, va_list arg); 
     63API_EXPORT(int) noit_log(noit_log_stream_t ls, struct timeval *, 
     64                         const char *file, int line, 
     65                         const char *format, ...) 
    6666#ifdef __GNUC__ 
    6767  __attribute__ ((format (printf, 5, 6)))