[srvx-commits] CVS: services/src log.c,1.55,1.56 log.h,1.24,1.25 main.c,1.148,1.149
                
                Brought to you by:
                
                    entrope
                    
                
            
            
        
        
        
    | 
      
      
      From: Zoot <zo...@us...> - 2003-07-10 23:06:25
      
     | 
| Update of /cvsroot/srvx/services/src
In directory sc8-pr-cvs1:/tmp/cvs-serv4680/src
Modified Files:
	log.c log.h main.c 
Log Message:
Restore support for the -d (debug mode) command line switch, which forces srvx to print log messages of all facilities and severities to standard out.
Index: log.c
===================================================================
RCS file: /cvsroot/srvx/services/src/log.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -r1.55 -r1.56
*** log.c	9 Jul 2003 04:49:22 -0000	1.55
--- log.c	10 Jul 2003 23:06:22 -0000	1.56
***************
*** 139,143 ****
  logList_join(struct logList *target, const struct logList *source)
  {
!     unsigned int ii, jj;
  
      if (!source->used) {
--- 139,143 ----
  logList_join(struct logList *target, const struct logList *source)
  {
!     unsigned int ii, jj, kk;
  
      if (!source->used) {
***************
*** 149,152 ****
--- 149,164 ----
      target->list = realloc(target->list, target->size * sizeof(target->list[0]));
      for (ii = 0; ii < source->used; ++ii, ++jj) {
+         int dup;
+         for (dup = 0, kk = 0; kk < jj; kk++) {
+             if (target->list[kk] == source->list[ii]) {
+                 dup = 1;
+                 break;
+             }
+         }
+         if (dup) {
+             jj--;
+             target->used--;
+             continue;
+         }
          target->list[jj] = source->list[ii];
          target->list[jj]->refcnt++;
***************
*** 363,366 ****
--- 375,396 ----
          free_string_list(slist);
      }
+ }
+ 
+ void
+ log_debug(void)
+ {
+     enum log_severity sev;
+     struct logDestination *log_stdout;
+     struct logList target;
+ 
+     log_stdout = log_open("std:out");
+     logList_init(&target);
+     logList_append(&target, log_stdout);
+ 
+     for(sev = 0; sev < LOG_NUM_SEVERITIES; ++sev) {
+         logList_join(&log_default->logs[sev], &target);
+     }
+ 
+     logList_close(&target);
  }
  
Index: log.h
===================================================================
RCS file: /cvsroot/srvx/services/src/log.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** log.h	7 Jul 2003 16:29:33 -0000	1.24
--- log.h	10 Jul 2003 23:06:22 -0000	1.25
***************
*** 41,44 ****
--- 41,46 ----
  void log_init(void);
  void log_reopen(void);
+ void log_debug(void);
+ 
  
  /* bitmap values in flags parameter to log_audit */
Index: main.c
===================================================================
RCS file: /cvsroot/srvx/services/src/main.c,v
retrieving revision 1.148
retrieving revision 1.149
diff -C2 -r1.148 -r1.149
*** main.c	7 Jul 2003 16:29:33 -0000	1.148
--- main.c	10 Jul 2003 23:06:22 -0000	1.149
***************
*** 583,586 ****
--- 583,587 ----
      printf("Usage: %s [-c config] [-r log] [-d] [-f] [-v|-h]\n"
             "-c, --config                    selects a different configuration file.\n"
+            "-d, --debug                     enables debug mode.\n"
             "-f, --foreground                run srvx in the foreground.\n"
             "-h, --help                      prints this usage message.\n"
***************
*** 625,629 ****
  int main(int argc, char *argv[])
  {
!     int daemon;
      pid_t pid = 0;
      FILE *file_out;
--- 626,630 ----
  int main(int argc, char *argv[])
  {
!     int daemon, debug;
      pid_t pid = 0;
      FILE *file_out;
***************
*** 631,634 ****
--- 632,636 ----
  
      daemon = 1;
+     debug = 0;
      tools_init();
  
***************
*** 652,655 ****
--- 654,658 ----
  	{
  	    {"config", 1, 0, 'c'},
+             {"debug", 0, 0, 'd'},
  	    {"foreground", 0, 0, 'f'},
  	    {"help", 0, 0, 'h'},
***************
*** 681,684 ****
--- 684,690 ----
                  }
                  break;
+             case 'd':
+                 debug = 1;
+                 break;
  	    case 'f':
  		daemon = 0;
***************
*** 759,762 ****
--- 765,771 ----
      log_init();
      MAIN_LOG = log_register_type("srvx", NULL, "file:main.log");
+     if (debug) {
+         log_debug();
+     }
      timeq_init();
      modcmd_init();
 |