]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
removed loglevel from global namespace. severity level is set using log() with a...
authorBruce Montrose <montrose@itd.nrl.navy.mil>
Fri, 12 Jul 2002 18:14:17 +0000 (18:14 +0000)
committerBruce Montrose <montrose@itd.nrl.navy.mil>
Fri, 12 Jul 2002 18:14:17 +0000 (18:14 +0000)
svn:r44

src/common/log.c
src/httpap/httpap.c
src/op/op.c
src/or/main.c
src/or/test_config.c
src/smtpap/smtpap.c

index e85f2c9464e9b499059e61bdc900d1a3091f2f03..27212aeabcce80a08089823e6bbea6a637dfaf28 100644 (file)
@@ -8,8 +8,11 @@
 /*
  * Changes :
  * $Log$
- * Revision 1.1  2002/06/26 22:45:50  arma
- * Initial revision
+ * Revision 1.2  2002/07/12 18:14:16  montrose
+ * removed loglevel from global namespace. severity level is set using log() with a NULL format argument now. example: log(LOG_ERR,NULL);
+ *
+ * Revision 1.1.1.1  2002/06/26 22:45:50  arma
+ * initial commit: current code
  *
  * Revision 1.11  2002/06/14 20:44:57  mp292
  * *** empty log message ***
 #include <errno.h>
 #include "log.h"
 
-void log_internal(int severity, const char *format, va_list ap);
-
 /* Outputs a message to stdout */
 void log(int severity, const char *format, ...)
 {
-  extern int loglevel;
+  static int loglevel = LOG_DEBUG;
   va_list ap;
 
-  va_start(ap,format);
-
-  if (severity <= loglevel)
+  if ( format )
   {
-    vprintf(format,ap);
-    printf("\n");
-  }
+
+    va_start(ap,format);
   
-  va_end(ap);
+    if (severity <= loglevel)
+    {
+      vprintf(format,ap);
+      printf("\n");
+    }
+    
+    va_end(ap);
+  }
+  else
+    loglevel = severity;
 }
index 93fb2bc5e0243f0811c43c9680a4195f3c083a30..4467c90333f1cce63847e290f239d961531f37ac 100644 (file)
@@ -8,6 +8,9 @@
 /*
  * Changes :
  * $Log$
+ * Revision 1.3  2002/07/12 18:14:16  montrose
+ * removed loglevel from global namespace. severity level is set using log() with a NULL format argument now. example: log(LOG_ERR,NULL);
+ *
  * Revision 1.2  2002/07/02 09:16:16  arma
  * httpap now prepends dest_addr and dest_port strings with their length.
  *
@@ -58,7 +61,6 @@
 #include "httpap.h"
 #include "http.h"
 
-int loglevel = LOG_ERR;
 struct timeval conn_tout;
 struct timeval *conn_toutp = &conn_tout;
 
@@ -464,6 +466,7 @@ int handle_connection(int new_sock, struct hostent *local, struct sockaddr_in re
 
 int main(int argc, char *argv[])
 {
+  int loglevel = LOG_DEBUG;
   int retval = 0;
   
   char c; /* command-line option */
@@ -522,7 +525,7 @@ int main(int argc, char *argv[])
       print_usage();
       return 0;
       break;
-     case 'l':
+    case 'l':
       if (!strcmp(optarg,"emerg"))
        loglevel = LOG_EMERG;
       else if (!strcmp(optarg,"alert"))
@@ -559,6 +562,8 @@ int main(int argc, char *argv[])
     }
   }
   
+  log(loglevel,NULL);  /* assign severity level for logger */
+
   /* the -f option is mandatory */
   if (conf_filename == NULL)
   {
index 06ae999503987932dbb7ec6a52e01c78dd1a42b2..797f2f50b931c159b2c58a19e2aa1888045b0cd0 100644 (file)
@@ -8,8 +8,11 @@
 /*
  * Changes :
  * $Log$
- * Revision 1.1  2002/06/26 22:45:50  arma
- * Initial revision
+ * Revision 1.2  2002/07/12 18:14:16  montrose
+ * removed loglevel from global namespace. severity level is set using log() with a NULL format argument now. example: log(LOG_ERR,NULL);
+ *
+ * Revision 1.1.1.1  2002/06/26 22:45:50  arma
+ * initial commit: current code
  *
  * Revision 1.37  2002/06/14 20:45:56  mp292
  * *** empty log message ***
 /* global variables */
 
 /* default logging threshold */
-int loglevel = LOG_ERR;
 struct timeval conn_tout;
 struct timeval *conn_toutp = &conn_tout; 
 
@@ -702,6 +704,8 @@ int main(int argc, char *argv[])
   int islocal = 0; /* is the incoming connection local? */
 
   struct rlimit cd_limit; /* resource limit to prevent core dumps */
+
+  log(LOG_ERR,NULL);  /* assign severity level for logger */
   
   /* prevent core dump */
   retval = getrlimit(RLIMIT_CORE, &cd_limit);
index 671cc72e242c87b581c21e944b6e22bd058e5fcf..b40ef9ee25f5ec275095ad3aac4151ca317b3c63 100644 (file)
@@ -4,7 +4,6 @@
 /********* START VARIABLES **********/
 
 static or_options_t options; /* command-line and config-file options */
-int loglevel;
 int global_role;
 
 static connection_t *connection_array[MAXCONNECTIONS] =
@@ -332,9 +331,8 @@ int main(int argc, char *argv[]) {
   signal (SIGINT, catch); /* to catch ^c so we can exit cleanly */
 
   if ( getoptions(argc,argv,&options) ) exit(1);
-  /* assign global vars from options. maybe get rid of these globals later */
-  loglevel = options.loglevel;
-  global_role = options.GlobalRole;
+  log(options.loglevel,NULL);         /* assign logging severity level from options */
+  global_role = options.GlobalRole;   /* assign global_role from options. FIX: remove from global namespace later. */
 
   ERR_load_crypto_strings();
   retval = do_main_loop();
index 171adb659ad3748489743f4080f111e92e825e92..f9a3fdd40034a4f44820a350f23be7b3b3f880a1 100644 (file)
@@ -1,7 +1,5 @@
 #include "or.h"
 
-int loglevel;
-
 int main(int ac, char **av)
 {
    or_options_t options;
index 701dde809f610bcb60d2d2159b7d83832e3b3370..a420268a7c8ce1fbb7307f7b885b4a925dbc2801 100644 (file)
@@ -8,8 +8,11 @@
 /*
  * Changes :
  * $Log$
- * Revision 1.1  2002/06/26 22:45:50  arma
- * Initial revision
+ * Revision 1.2  2002/07/12 18:14:17  montrose
+ * removed loglevel from global namespace. severity level is set using log() with a NULL format argument now. example: log(LOG_ERR,NULL);
+ *
+ * Revision 1.1.1.1  2002/06/26 22:45:50  arma
+ * initial commit: current code
  *
  * Revision 1.32  2002/04/02 14:29:49  badbytes
  * Final finishes.
 #include "smtpap.h"
 #include "io.h"
 
-int loglevel = LOG_ERR;
 struct timeval conn_tout;
 struct timeval *conn_toutp = &conn_tout;
 
@@ -1141,6 +1143,7 @@ int handle_connection(int s, struct hostent *local, struct sockaddr_in remote, u
 
 int main(int argc, char *argv[])
 {
+  int loglevel = LOG_DEBUG;
   int retval = 0;
   
   char c; /* command-line option */
@@ -1166,7 +1169,7 @@ int main(int argc, char *argv[])
   struct sigaction sa;
   
   char *errtest = NULL; /* for detecting strtoul() errors */
-  
+
   /* set default listening port */
   p = htons(SMTPAP_LISTEN_PORT);
   
@@ -1198,7 +1201,7 @@ int main(int argc, char *argv[])
       print_usage();
       return 0;
       break;
-     case 'l':
+    case 'l':
       if (!strcmp(optarg,"emerg"))
        loglevel = LOG_EMERG;
       else if (!strcmp(optarg,"alert"))
@@ -1234,7 +1237,9 @@ int main(int argc, char *argv[])
       abort();
     }
   }
-  
+    
+  log(loglevel,NULL); /* assign severity level for logger */
+
   /* the -f option is mandatory */
   if (conf_filename == NULL)
   {