Log level is set to WARNING unless -d flag is used

-d flag now sets logging to debug
stable
Justin Reichardt 2021-08-30 11:46:02 -05:00
parent 0e431bec54
commit 74c0f189a0
2 changed files with 21 additions and 3 deletions

View File

@ -23,13 +23,19 @@
#include "rhosts.h"
#endif
int main(int argc, char *argv[]){
struct entry *entries;
struct config config;
config.loglevel = CLOGS_WARNING;
int rc =0;
if (argc >1){
consume_args(&config, argc, argv);
}
clogs_init_config(CLOGS_TIMESTAMP | CLOGS_USELOGFILE, \
"/var/log/rhosts.log", CLOGS_DEBUG);
"/var/log/rhosts.log", config.loglevel);
clogs_print(CLOGS_DEBUG,"Initialized settting up logs");
rc = parse_config(&entries);
@ -247,3 +253,11 @@ int copy_tmp_to_hosts(){
remove(TMPLOCATION);
return 0;
}
int consume_args(struct config *config, int argc, char **argv){
int i=0;
for (i=1;i < argc;i++){
if (strcmp(argv[i], "-d") == 0)
config->loglevel = CLOGS_DEBUG;
}
return 0;
}

View File

@ -56,6 +56,9 @@ struct entry{
int entrytype;
char entry[MAXSTRSIZE];
};
struct config{
uint8_t loglevel;
};
int parse_config(struct entry **entries);
@ -65,6 +68,7 @@ short int determine_config_entry_value(char *buff);
int preserve_static_entries();
int add_site_entries(struct entry **entries);
int copy_tmp_to_hosts();
int consume_args(struct config *config, int argc, char **argv);
#endif
#ifndef DOWNLOAD_HEADER
#include "download.h"