log level should be configured in config file

This commit is contained in:
lxsang 2021-10-08 22:33:16 +02:00
parent e7ec929709
commit e9cd1addf7
4 changed files with 15 additions and 6 deletions

View File

@ -161,6 +161,10 @@ static int config_handler(void *conf, const char *section, const char *name,
{ {
pconfig->n_workers = atoi(value); pconfig->n_workers = atoi(value);
} }
else if (MATCH("SERVER", "debug_enable"))
{
pconfig->debug_enable = atoi(value);
}
#ifdef USE_ZLIB #ifdef USE_ZLIB
else if (MATCH("SERVER", "gzip_enable")) else if (MATCH("SERVER", "gzip_enable"))
{ {
@ -269,6 +273,7 @@ void load_config(const char *file)
server_config.ssl_cipher = NULL; server_config.ssl_cipher = NULL;
server_config.gzip_enable = 0; server_config.gzip_enable = 0;
server_config.gzip_types = NULL; server_config.gzip_types = NULL;
server_config.debug_enable = 0;
// put it default mimes // put it default mimes
for (int i = 0; _mimes[i].type != NULL; i++) for (int i = 0; _mimes[i].type != NULL; i++)
{ {

View File

@ -339,7 +339,14 @@ int main(int argc, char *argv[])
config_t *conf = config(); config_t *conf = config();
// start syslog // start syslog
if(conf->debug_enable == 1)
{
setlogmask(LOG_UPTO(LOG_NOTICE)); setlogmask(LOG_UPTO(LOG_NOTICE));
}
else
{
setlogmask(LOG_UPTO(LOG_ERR));
}
openlog(SERVER_NAME, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON); openlog(SERVER_NAME, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON);
#ifdef USE_OPENSSL #ifdef USE_OPENSSL

View File

@ -93,6 +93,7 @@ typedef struct
char *sslkey; char *sslkey;
char *ssl_cipher; char *ssl_cipher;
int gzip_enable; int gzip_enable;
int debug_enable;
list_t gzip_types; list_t gzip_types;
dictionary_t mimes; dictionary_t mimes;
dictionary_t ports; dictionary_t ports;

View File

@ -43,12 +43,8 @@ THE SOFTWARE.
#define true 1 #define true 1
#define false 0 #define false 0
#ifdef DEBUG
#define LOG(a,...) syslog (LOG_NOTICE,"ANTD_LOG@[%s: %d]: " a "\n", __FILE__, \ #define LOG(a,...) syslog (LOG_NOTICE,"ANTD_LOG@[%s: %d]: " a "\n", __FILE__, \
__LINE__, ##__VA_ARGS__) __LINE__, ##__VA_ARGS__)
#else
#define LOG(a,...) do{}while(0)
#endif
#define ERROR(a,...) syslog (LOG_ERR, "ANTD_ERROR@[%s: %d]: " a "\n", __FILE__, \ #define ERROR(a,...) syslog (LOG_ERR, "ANTD_ERROR@[%s: %d]: " a "\n", __FILE__, \
__LINE__, ##__VA_ARGS__) __LINE__, ##__VA_ARGS__)
// add this to the utils // add this to the utils