removed loglevel from global namespace. severity level is set using log() with a NULL format argument now. example: log(LOG_ERR,NULL);

svn:r44
This commit is contained in:
Bruce Montrose 2002-07-12 18:14:17 +00:00
parent d00c39231d
commit be25ffd5d7
6 changed files with 46 additions and 29 deletions

View File

@ -8,8 +8,11 @@
/* /*
* Changes : * Changes :
* $Log$ * $Log$
* Revision 1.1 2002/06/26 22:45:50 arma * Revision 1.2 2002/07/12 18:14:16 montrose
* Initial revision * 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 * Revision 1.11 2002/06/14 20:44:57 mp292
* *** empty log message *** * *** empty log message ***
@ -54,14 +57,15 @@
#include <errno.h> #include <errno.h>
#include "log.h" #include "log.h"
void log_internal(int severity, const char *format, va_list ap);
/* Outputs a message to stdout */ /* Outputs a message to stdout */
void log(int severity, const char *format, ...) void log(int severity, const char *format, ...)
{ {
extern int loglevel; static int loglevel = LOG_DEBUG;
va_list ap; va_list ap;
if ( format )
{
va_start(ap,format); va_start(ap,format);
if (severity <= loglevel) if (severity <= loglevel)
@ -71,4 +75,7 @@ void log(int severity, const char *format, ...)
} }
va_end(ap); va_end(ap);
}
else
loglevel = severity;
} }

View File

@ -8,6 +8,9 @@
/* /*
* Changes : * Changes :
* $Log$ * $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 * Revision 1.2 2002/07/02 09:16:16 arma
* httpap now prepends dest_addr and dest_port strings with their length. * httpap now prepends dest_addr and dest_port strings with their length.
* *
@ -58,7 +61,6 @@
#include "httpap.h" #include "httpap.h"
#include "http.h" #include "http.h"
int loglevel = LOG_ERR;
struct timeval conn_tout; struct timeval conn_tout;
struct timeval *conn_toutp = &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 main(int argc, char *argv[])
{ {
int loglevel = LOG_DEBUG;
int retval = 0; int retval = 0;
char c; /* command-line option */ char c; /* command-line option */
@ -559,6 +562,8 @@ int main(int argc, char *argv[])
} }
} }
log(loglevel,NULL); /* assign severity level for logger */
/* the -f option is mandatory */ /* the -f option is mandatory */
if (conf_filename == NULL) if (conf_filename == NULL)
{ {

View File

@ -8,8 +8,11 @@
/* /*
* Changes : * Changes :
* $Log$ * $Log$
* Revision 1.1 2002/06/26 22:45:50 arma * Revision 1.2 2002/07/12 18:14:16 montrose
* Initial revision * 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 * Revision 1.37 2002/06/14 20:45:56 mp292
* *** empty log message *** * *** empty log message ***
@ -163,7 +166,6 @@
/* global variables */ /* global variables */
/* default logging threshold */ /* default logging threshold */
int loglevel = LOG_ERR;
struct timeval conn_tout; struct timeval conn_tout;
struct timeval *conn_toutp = &conn_tout; struct timeval *conn_toutp = &conn_tout;
@ -703,6 +705,8 @@ int main(int argc, char *argv[])
struct rlimit cd_limit; /* resource limit to prevent core dumps */ struct rlimit cd_limit; /* resource limit to prevent core dumps */
log(LOG_ERR,NULL); /* assign severity level for logger */
/* prevent core dump */ /* prevent core dump */
retval = getrlimit(RLIMIT_CORE, &cd_limit); retval = getrlimit(RLIMIT_CORE, &cd_limit);
if (retval == -1) if (retval == -1)

View File

@ -4,7 +4,6 @@
/********* START VARIABLES **********/ /********* START VARIABLES **********/
static or_options_t options; /* command-line and config-file options */ static or_options_t options; /* command-line and config-file options */
int loglevel;
int global_role; int global_role;
static connection_t *connection_array[MAXCONNECTIONS] = 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 */ signal (SIGINT, catch); /* to catch ^c so we can exit cleanly */
if ( getoptions(argc,argv,&options) ) exit(1); if ( getoptions(argc,argv,&options) ) exit(1);
/* assign global vars from options. maybe get rid of these globals later */ log(options.loglevel,NULL); /* assign logging severity level from options */
loglevel = options.loglevel; global_role = options.GlobalRole; /* assign global_role from options. FIX: remove from global namespace later. */
global_role = options.GlobalRole;
ERR_load_crypto_strings(); ERR_load_crypto_strings();
retval = do_main_loop(); retval = do_main_loop();

View File

@ -1,7 +1,5 @@
#include "or.h" #include "or.h"
int loglevel;
int main(int ac, char **av) int main(int ac, char **av)
{ {
or_options_t options; or_options_t options;

View File

@ -8,8 +8,11 @@
/* /*
* Changes : * Changes :
* $Log$ * $Log$
* Revision 1.1 2002/06/26 22:45:50 arma * Revision 1.2 2002/07/12 18:14:17 montrose
* Initial revision * 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 * Revision 1.32 2002/04/02 14:29:49 badbytes
* Final finishes. * Final finishes.
@ -133,7 +136,6 @@
#include "smtpap.h" #include "smtpap.h"
#include "io.h" #include "io.h"
int loglevel = LOG_ERR;
struct timeval conn_tout; struct timeval conn_tout;
struct timeval *conn_toutp = &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 main(int argc, char *argv[])
{ {
int loglevel = LOG_DEBUG;
int retval = 0; int retval = 0;
char c; /* command-line option */ char c; /* command-line option */
@ -1235,6 +1238,8 @@ int main(int argc, char *argv[])
} }
} }
log(loglevel,NULL); /* assign severity level for logger */
/* the -f option is mandatory */ /* the -f option is mandatory */
if (conf_filename == NULL) if (conf_filename == NULL)
{ {