5 /* =========================================================================
7 logger.c is part of the utils section in the libatalk library,
8 which is part of the netatalk project.
10 logger.c was written by Simon Bazley (sibaz@sibaz.com)
12 I believe libatalk is released under the L/GPL licence.
14 Just incase, it is, thats the licence I'm applying to this file.
18 ==========================================================================
20 Logger.c is intended as an alternative to syslog for logging
22 ---------------------------------------------------------------
24 The initial plan is to create a structure for general information needed
27 Initally I'll hard code the neccesary stuff to start a log, this should
28 probably be moved elsewhere when some code is written to read the log
29 file locations from the config files.
31 As a more longterm idea, I'll code this so that the data struct can be
32 duplicated to allow multiple concurrent log files, although this is
33 probably a recipe for wasted resources.
35 ========================================================================= */
43 #include <sys/types.h>
48 #include <atalk/boolean.h>
49 #include <atalk/logger.h>
51 #define COUNT_ARRAY(array) (sizeof((array))/sizeof((array)[0]))
52 #define NUMOF COUNT_ARRAY
53 #undef KEEP_LOGFILES_OPEN
57 #undef DEBUG_OUTPUT_TO_SCREEN
58 #undef CHECK_STAT_ON_NEW_FILES
59 #undef CHECK_ACCESS_ON_NEW_FILES
61 /* =========================================================================
62 External function declarations
63 ========================================================================= */
65 /* setup the internal variables used by the logger (called automatically) */
68 /* Setup the log filename and the loglevel, and the type of log it is. */
69 bool log_setup(char *filename, enum loglevels loglevel, enum logtypes logtype,
72 /* Setup the Level and type of log that will be logged to syslog. */
73 void syslog_setup(enum loglevels loglevel, enum logtypes logtype,
74 int display_options, int facility);
76 /* finish up and close the logs */
79 /* This function sets up the processname */
80 void set_processname(char *processname);
83 void make_log(enum loglevels loglevel, enum logtypes logtype,
85 #ifndef DISABLE_LOGGER
86 make_log_func set_log_location(char *srcfilename, int srclinenumber);
88 /* =========================================================================
90 ========================================================================= */
92 /* A structure containing object level stuff */
93 struct tag_log_file_data {
94 char log_filename[PATH_MAX]; /* Name of file */
95 FILE *log_file; /* FILE pointer to file */
96 enum loglevels log_level; /* Log Level to put in this file */
100 typedef struct tag_log_file_data log_file_data_pair[2];
102 /* A structure containg class level stuff */
103 struct tag_global_log_data {
106 char *temp_src_filename;
107 int temp_src_linenumber;
108 char processname[16];
111 char *log_file_directory; /* Path of directory containing log files */
112 log_file_data_pair **logs;
115 struct what_to_print_array {
117 bool print_processname;
125 /* =========================================================================
126 Internal function declarations
127 ========================================================================= */
129 void generate_message_details(char *message_details_buffer,
130 int message_details_buffer_length,
131 struct tag_log_file_data *log_struct,
132 enum loglevels loglevel, enum logtypes logtype);
134 int get_syslog_equivalent(enum loglevels loglevel);
136 static char *get_command_name(char *commandpath);
138 /* =========================================================================
140 ========================================================================= */
142 /* A populated instance */
144 static log_file_data_pair default_log_file_data_pair = {
146 log_filename: "\0\0\0\0\0\0\0\0",
148 log_level: log_debug,
149 display_options: logoption_pid
152 log_filename: LOGFILEPATH,
154 log_level: log_debug,
155 display_options: logoption_pid
158 static log_file_data_pair *log_file_data_array[logtype_end_of_list_marker] =
159 {&default_log_file_data_pair};
161 /* The class (populated) */
162 static struct tag_global_log_data global_log_data = {
163 struct_size: sizeof(struct tag_global_log_data),
164 temp_src_filename: NULL,
165 temp_src_linenumber: 0,
167 facility: logfacility_daemon,
168 log_file_directory: "",
172 /* macro to get access to the array */
173 #define log_file_arr (global_log_data.logs)
175 /* Array to store text to list given a log type */
176 static const char * arr_logtype_strings[] = LOGTYPE_STRING_IDENTIFIERS;
177 static const int num_logtype_strings = COUNT_ARRAY(arr_logtype_strings);
179 /* Array for charachters representing log severity in the log file */
180 static const char arr_loglevel_chars[] = {'S', 'E', 'W', 'N', 'I', 'D'};
181 static const int num_loglevel_chars = COUNT_ARRAY(arr_loglevel_chars);
183 static const char * arr_loglevel_strings[] = LOGLEVEL_STRING_IDENTIFIERS;
184 static const int num_loglevel_strings = COUNT_ARRAY(arr_loglevel_strings);
186 #else /* #ifndef DISABLE_LOGGER */
187 char *disabled_logger_processname=NULL;
188 #endif /* DISABLE_LOGGER */
189 /* =========================================================================
190 Global function definitions
191 ========================================================================= */
193 #ifndef DISABLE_LOGGER
195 /* remember I'm keeping a copy of the actual char * Filename, so you mustn't
196 delete it, until you've finished with the log. Also you're responsible
197 for deleting it when you have finished with it. */
200 if (global_log_data.logs==NULL)
202 /* first check default_log_file_data_pair */
204 /* next clear out the log_file_data_array */
205 memset(log_file_data_array, 0, sizeof(log_file_data_array));
206 /* now set default_log_file_data_pairs */
207 log_file_data_array[0] = &default_log_file_data_pair;
209 /* now setup the global_log_data struct */
210 global_log_data.logs = log_file_data_array;
213 #endif /* #ifndef DISABLE_LOGGER */
215 bool log_setup(char *filename, enum loglevels loglevel, enum logtypes logtype,
218 #ifndef DISABLE_LOGGER
228 log_file_data_pair *logs;
232 logs = log_file_arr[logtype];
236 logs = (log_file_data_pair *)malloc(sizeof(log_file_data_pair));
239 LOG(log_severe, logtype_logger, "can't calloc in log_setup");
244 memcpy(logs, log_file_arr[logtype_default], sizeof(log_file_data_pair));
246 log_file_arr[logtype] = logs;
247 (*logs)[1].log_file = NULL;
251 if ( ((*logs)[1].log_file == stdout) && ((*logs)[1].log_file != NULL) )
253 fclose((*logs)[1].log_file);
254 (*logs)[1].log_file = NULL;
257 if (strlen(global_log_data.log_file_directory)>0)
259 lastchar[0] = global_log_data.
260 log_file_directory[strlen(global_log_data.log_file_directory)-1];
262 if (lastchar[0] == '/' || lastchar[0] == '\\' || lastchar[0] == ':')
265 /* this should probably be a platform specific path separator */
273 #ifdef DEBUG_OUTPUT_TO_SCREEN
274 printf("filename is %s stored at location %p\n", (*logs)[1].log_filename,
275 (*logs)[1].log_filename);
276 #endif /* DEBUG_OUTPUT_TO_SCREEN */
277 if (filename == NULL)
279 strncpy((*logs)[1].log_filename,
280 (*(log_file_arr[0]))[1].log_filename, PATH_MAX);
284 sprintf((*logs)[1].log_filename, "%s%s%s",
285 global_log_data.log_file_directory,
288 (*logs)[1].log_level = loglevel;
289 (*logs)[1].display_options = display_options;
291 #ifdef DEBUG_OUTPUT_TO_SCREEN
292 printf("filename is %s stored at location %p\n", (*logs)[1].log_filename,
293 (*logs)[1].log_filename);
294 #endif /* DEBUG_OUTPUT_TO_SCREEN */
296 #ifdef CHECK_STAT_ON_NEW_FILES
300 #ifdef DEBUG_OUTPUT_TO_SCREEN
301 printf("about to stat file %s\n", (*logs)[1].log_filename);
303 firstattempt = stat((*logs)[1].log_filename, &statbuf);
305 if (firstattempt == -1)
307 #ifdef DEBUG_OUTPUT_TO_SCREEN
308 printf("about to call Log with %d, %d, %s, %s\n",
309 log_note, logtype_logger,
310 "can't stat Logfile",
311 (*logs)[1].log_filename
315 /* syslog(LOG_INFO, "stat failed"); */
316 LOG(log_warning, logtype_logger, "stat fails on file %s",
317 (*logs)[1].log_filename);
319 if (strlen(global_log_data.log_file_directory)>0)
321 retval = stat(global_log_data.log_file_directory, &statbuf);
324 #ifdef DEBUG_OUTPUT_TO_SCREEN
325 printf("can't stat dir either so I'm giving up\n");
327 LOG(log_severe, logtype_logger, "can't stat directory %s either",
328 global_log_data.log_file_directory);
334 #ifdef CHECK_ACCESS_ON_NEW_FILES
335 access = ((statbuf.st_uid == uid)?(statbuf.st_mode & S_IWUSR):0) +
336 ((statbuf.st_gid == gid)?(statbuf.st_mode & S_IWGRP):0) +
337 (statbuf.st_mode & S_IWOTH);
341 #ifdef DEBUG_OUTPUT_TO_SCREEN
342 printf("failing with %d, %d, %s, %s\n", log_note, logtype_logger,
343 "can't access Logfile %s", (*logs)[1].log_filename);
346 LOG(log_note, logtype_logger, "can't access file %s",
347 (*logs)[1].log_filename);
350 #endif /* CHECK_ACCESS_ON_NEW_FILES */
351 #endif /* CHECK_STAT_ON_NEW_FILES */
352 #ifdef KEEP_LOGFILES_OPEN
353 if ((*logs)[1].log_file!=NULL)
354 fclose((*logs)[1].log_file);
356 (*logs)[1].log_file = fopen((*logs)[1].log_filename, "at");
357 if ((*logs)[1].log_file == NULL)
359 LOG(log_severe, logtype_logger, "can't open Logfile %s",
360 (*logs)[1].log_filename
366 LOG(log_info, logtype_logger, "Log setup complete");
368 #endif /* DISABLE_LOGGER */
373 void syslog_setup(enum loglevels loglevel, enum logtypes logtype,
374 int display_options, int facility)
376 #ifndef DISABLE_LOGGER
377 log_file_data_pair *logs;
381 logs = log_file_arr[logtype];
385 logs = (log_file_data_pair *)malloc(sizeof(log_file_data_pair));
388 LOG(log_severe, logtype_logger, "can't calloc in log_setup");
392 memcpy(logs, log_file_arr[logtype_default], sizeof(log_file_data_pair));
393 log_file_arr[logtype] = logs;
397 (*logs)[0].log_file = NULL;
398 (*logs)[0].log_filename[0] = 0;
399 (*logs)[0].log_level = loglevel;
400 (*logs)[0].display_options = display_options;
401 global_log_data.facility = facility;
403 openlog(global_log_data.processname, (*logs)[0].display_options,
404 global_log_data.facility);
406 LOG(log_info, logtype_logger, "SysLog setup complete");
407 #else /* DISABLE_LOGGER */
408 /* behave like a normal openlog call */
409 openlog(disabled_logger_processname, display_options, facility);
410 #endif /* DISABLE_LOGGER */
415 #ifndef DISABLE_LOGGER
416 log_file_data_pair *logs;
419 LOG(log_info, logtype_logger, "Closing logs");
421 for(n=(sizeof(log_file_arr)-1);n>0;n--)
423 logs = log_file_arr[n];
424 #ifdef KEEP_LOGFILES_OPEN
425 if ((*logs)[1].log_file!=NULL)
426 fclose((*logs)[1].log_file);
427 #endif /* KEEP_LOGFILES_OPEN */
430 #ifdef DEBUG_OUTPUT_TO_SCREEN
431 printf("Freeing log_data %d, stored at %p\n", n, logs);
432 printf("\t(filename) %s\t(type) %s\n", (*logs)[1].log_filename,
433 ((n<num_logtype_strings)?arr_logtype_strings[n]:""));
434 #endif /* DEBUG_OUTPUT_TO_SCREEN */
437 log_file_arr[n] = NULL;
439 #ifdef DEBUG_OUTPUT_TO_SCREEN
440 printf("Freeing log_data %d, stored at %p\n", n, log_file_arr[n]);
441 printf("\t(filename) %s\t(type) %s\n",
442 (*(log_file_arr[n]))[1].log_filename,
443 ((n<num_logtype_strings)?arr_logtype_strings[n]:"")
445 #endif /* DEBUG_OUTPUT_TO_SCREEN */
446 #endif /* DISABLE_LOGGER */
451 /* This function sets up the processname */
452 void set_processname(char *processname)
454 #ifndef DISABLE_LOGGER
455 /* strncpy(global_log_data.processname, GetCommandName(processname), 15); */
456 strncpy(global_log_data.processname, processname, 15);
457 global_log_data.processname[15] = 0;
458 #else /* DISABLE_LOGGER */
459 disabled_logger_processname = processname;
460 #endif /* DISABLE_LOGGER */
463 #ifndef DISABLE_LOGGER
464 /* This is called by the macro so set the location of the caller of Log */
465 make_log_func set_log_location(char *srcfilename, int srclinenumber)
467 #ifdef DEBUG_OUTPUT_TO_SCREEN
468 printf("Setting Log Location\n");
470 global_log_data.temp_src_filename = srcfilename;
471 global_log_data.temp_src_linenumber = srclinenumber;
473 return make_log_entry;
475 #endif /* DISABLE_LOGGER */
477 /* -------------------------------------------------------------------------
478 MakeLog has 1 main flaws:
479 The message in its entirity, must fit into the tempbuffer.
480 So it must be shorter than MAXLOGSIZE
481 ------------------------------------------------------------------------- */
482 void make_log_entry(enum loglevels loglevel, enum logtypes logtype,
486 char log_buffer[MAXLOGSIZE];
487 #ifndef DISABLE_LOGGER
488 char log_details_buffer[MAXLOGSIZE];
490 log_file_data_pair *logs;
494 logs = log_file_arr[logtype];
498 logs = log_file_arr[logtype_default];
500 #ifdef DEBUG_OUTPUT_TO_SCREEN
501 printf("Making Log\n");
504 #endif /* DISABLE_LOGGER */
506 /* Initialise the Messages */
507 va_start(args, message);
509 vsnprintf(log_buffer, sizeof(log_buffer), message, args);
511 /* Finished with args for now */
514 #ifdef DISABLE_LOGGER
515 syslog(get_syslog_equivalent(loglevel), "%s", log_buffer);
516 #else /* DISABLE_LOGGER */
519 /* check if sysloglevel is high enough */
520 if ((*logs)[0].log_level>=loglevel)
522 int sysloglevel = get_syslog_equivalent(loglevel);
524 generate_message_details(log_details_buffer, sizeof(log_details_buffer),
525 &(*logs)[0], loglevel, logtype);
527 #ifdef DEBUG_OUTPUT_TO_SCREEN
528 printf("About to log %s %s\n", log_details_buffer, log_buffer);
529 printf("about to do syslog\n");
530 printf("done onw syslog\n");
532 syslog(sysloglevel, "%s: %s", log_details_buffer, log_buffer);
534 syslog(sysloglevel, "%s:%s: %s", log_levelString,
535 log_typeString, LogBuffer);
541 #ifdef DEBUG_OUTPUT_TO_SCREEN
542 printf("about to do the filelog\n");
544 /* check if log_level is high enough */
545 if ((*logs)[1].log_level>=loglevel) {
547 #ifdef DEBUG_OUTPUT_TO_SCREEN
548 printf("Open the Log, FILE* is %p\n", (*logs)[1].log_file);
550 /* if log isn't open, open it */
551 if ((*logs)[1].log_file==NULL) {
552 #ifdef DEBUG_OUTPUT_TO_SCREEN
553 printf("Opening the Log, filename is %s\n", (*logs)[1].log_filename);
555 (*logs)[1].log_file = fopen((*logs)[1].log_filename, "at");
556 if ((*logs)[1].log_file == NULL)
558 (*logs)[1].log_file = stdout;
559 LOG(log_severe, logtype_logger, "can't open Logfile %s",
560 (*logs)[1].log_filename
565 generate_message_details(log_details_buffer, sizeof(log_details_buffer),
566 &(*logs)[1], loglevel, logtype);
568 #ifdef DEBUG_OUTPUT_TO_SCREEN
569 printf("Files open, lets log\n");
570 printf("FILE* is %p\n", (*logs)[1].log_file);
571 printf("%s: %s\n", log_details_buffer, log_buffer);
574 fprintf((*logs)[1].log_file, "%s: %s\n", log_details_buffer, log_buffer);
576 #ifndef KEEP_LOGFILES_OPEN
577 if ((*logs)[1].log_file != stdout)
579 #ifdef DEBUG_OUTPUT_TO_SCREEN
580 printf("Closing %s\n", (*logs)[1].log_filename);
582 fclose((*logs)[1].log_file);
583 (*logs)[1].log_file = NULL;
584 #ifdef DEBUG_OUTPUT_TO_SCREEN
592 global_log_data.temp_src_filename = NULL;
593 global_log_data.temp_src_linenumber = 0;
594 #endif /* DISABLE_LOGGER */
597 #ifndef DISABLE_LOGGER
598 void load_proccessname_from_proc()
600 pid_t pid = getpid();
601 char buffer[PATH_MAX];
606 sprintf(buffer, "/proc/%d/stat", pid);
607 statfile = fopen(buffer, "rt");
608 fgets(buffer, PATH_MAX-1, statfile);
611 ptr = (char *)strrchr(buffer, ')');
613 memset(procname, 0, sizeof procname);
614 sscanf(buffer, "%d (%15c", &pid, procname); /* comm[16] in kernel */
616 set_processname(procname);
619 /* =========================================================================
620 Internal function definitions
621 ========================================================================= */
623 static char *get_command_name(char *commandpath)
626 #ifdef DEBUG_OUTPUT_TO_SCREEN
627 printf("getting command name %s\n",commandpath);
629 ptr = (char *)strrchr(commandpath, '/');
635 #ifdef DEBUG_OUTPUT_TO_SCREEN
636 printf("Concluded %s\n", ptr);
641 void workout_what_to_print(struct what_to_print_array *what_to_print,
642 struct tag_log_file_data *log_struct)
644 /* is this a syslog entry? */
645 if (log_struct->log_filename[0]==0)
647 what_to_print->print_datetime = false;
648 what_to_print->print_processname = false;
649 what_to_print->print_pid = false;
653 what_to_print->print_datetime = true;
654 what_to_print->print_processname = true;
656 /* pid is dealt with at the syslog level if we're syslogging */
657 what_to_print->print_pid =
658 (((log_struct->display_options & logoption_pid) == 0)?false:true);
661 what_to_print->print_srcfile =
662 (((log_struct->display_options & logoption_nfile) == 0)?true:false);
663 what_to_print->print_srcline =
664 (((log_struct->display_options & logoption_nline) == 0)?true:false);
666 what_to_print->print_errlevel = true;
667 what_to_print->print_errtype = true;
670 void generate_message_details(char *message_details_buffer,
671 int message_details_buffer_length,
672 struct tag_log_file_data *log_struct,
673 enum loglevels loglevel, enum logtypes logtype)
676 char processinfo[64];
678 char *ptr = message_details_buffer;
680 int len = message_details_buffer_length;
682 char log_buffer[MAXLOGSIZE];
683 const char *logtype_string;
685 char loglevel_string[12]; /* max int size is 2 billion, or 10 digits */
687 struct what_to_print_array what_to_print;
689 workout_what_to_print(&what_to_print, log_struct);
691 #ifdef DEBUG_OUTPUT_TO_SCREEN
692 printf("Making MessageDetails\n");
701 if (what_to_print.print_datetime)
706 /* some people might prefer localtime() to gmtime() */
707 strftime(ptr, len, "%b %d %H:%M:%S", localtime(&thetime));
708 #ifdef DEBUG_OUTPUT_TO_SCREEN
709 printf("date is %s\n", ptr);
712 templen = strlen(ptr);
714 if (what_to_print.print_processname || what_to_print.print_pid)
715 strncat(ptr, " ", len);
717 strncat(ptr, ":", len);
729 if (what_to_print.print_processname)
731 strncpy(ptr, global_log_data.processname, len);
733 templen = strlen(ptr);
738 if (what_to_print.print_pid)
740 pid_t pid = getpid();
742 sprintf(ptr, "[%d]", pid);
744 templen = strlen(ptr);
749 if (what_to_print.print_srcfile || what_to_print.print_srcline)
751 char sprintf_buffer[8];
754 sprintf_buffer[0] = '[';
755 if (what_to_print.print_srcfile)
757 strcpy(&sprintf_buffer[1], "%s");
758 buff_ptr = &sprintf_buffer[3];
760 if (what_to_print.print_srcfile && what_to_print.print_srcline)
762 strcpy(&sprintf_buffer[3], ":");
763 buff_ptr = &sprintf_buffer[4];
765 if (what_to_print.print_srcline)
767 strcpy(buff_ptr, "%d");
768 buff_ptr = &buff_ptr[2];
770 strcpy(buff_ptr, "]");
773 ok sprintf string is ready, now is the 1st parameter src or linenumber
775 if (what_to_print.print_srcfile)
777 sprintf(ptr, sprintf_buffer,
778 global_log_data.temp_src_filename,
779 global_log_data.temp_src_linenumber);
783 sprintf(ptr, sprintf_buffer, global_log_data.temp_src_linenumber);
786 #ifdef DEBUG_OUTPUT_TO_SCREEN
787 printf("Process info is %s\n", ptr);
790 templen = strlen(ptr);
796 if (what_to_print.print_processname || what_to_print.print_pid ||
797 what_to_print.print_srcfile || what_to_print.print_srcline)
799 strncat(ptr, ": ", len);
805 loglevel_string[0] = 0;
806 ptr = loglevel_string;
809 if (what_to_print.print_errlevel)
811 if ((loglevel/10) >= (num_loglevel_chars-1))
813 sprintf(ptr, "%c%d", arr_loglevel_chars[num_loglevel_chars-1],
818 sprintf(ptr, "%c", arr_loglevel_chars[loglevel/10]);
821 templen = strlen(ptr);
826 if (what_to_print.print_errtype)
828 const char *logtype_string;
830 /* get string represnetation of the Log Type */
831 if (logtype<num_logtype_strings)
832 logtype_string = arr_logtype_strings[logtype];
836 if (what_to_print.print_errlevel)
838 strncat(ptr, ":", len);
842 sprintf(ptr, "%s", logtype_string);
845 message_details_buffer[message_details_buffer_length-1] = 0;
847 #ifdef DEBUG_OUTPUT_TO_SCREEN
848 printf("Message Details are %s\n", message_details_buffer);
851 #endif /* DISABLE_LOGGER */
853 int get_syslog_equivalent(enum loglevels loglevel)
857 /* The question is we know how bad it is for us,
858 but how should that translate in the syslogs? */
863 case 2: /* warning */
867 case 4: /* information */
874 /* void setuplog(char *logsource, char *logtype, char *loglevel, char *filename) */
875 void setuplog(char *logtype, char *loglevel, char *filename)
877 #ifndef DISABLE_LOGGER
878 /* -setuplogtype <syslog|filelog> <logtype> <loglevel>*/
879 /* -setuplogtype <logtype> <loglevel> [<filename>]*/
881 This should be rewritten so that somehow logsource is assumed and everything
882 can be taken from default if needs be.
884 /* const char* sources[] = {"syslog", "filelog"}; */
885 const char *null = "";
886 int sourcenum, typenum, levelnum;
887 log_file_data_pair *logs = log_file_arr[logtype_default];
890 LOG(log_extradebug, logtype_logger, "Attempting setuplog: %s %s %s %s",
891 logsource, logtype, loglevel, filename);
893 LOG(log_extradebug, logtype_logger, "Attempting setuplog: %s %s %s",
894 logtype, loglevel, filename);
910 * We'll just use filename, if its NULL we know its a syslog thing
914 LOG(log_note, logtype_logger, "no logsource given");
918 for(sourcenum=0;sourcenum<NUMOF(sources);sourcenum++)
920 if (strcasecmp(logsource, sources[sourcenum])==0)
923 if (sourcenum>=NUMOF(sources))
925 LOG(log_warning, logtype_logger, "%s is not a valid log source", logsource);
927 if ((sourcenum>0) && (filename==NULL))
929 LOG(log_warning, logtype_logger,
930 "when specifying a filelog, you must specify a valid filename");
937 LOG(log_note, logtype_logger, "no logsource given");
941 for(typenum=0;typenum<num_logtype_strings;typenum++)
943 if (strcasecmp(logtype, arr_logtype_strings[typenum])==0)
946 if (typenum>=num_logtype_strings)
948 LOG(log_warning, logtype_logger, "%s is not a valid log type", logtype);
954 LOG(log_note, logtype_logger, "no loglevel given");
958 for(levelnum=0;levelnum<num_loglevel_strings;levelnum++)
960 if (strcasecmp(loglevel, arr_loglevel_strings[levelnum])==0)
963 if (levelnum>=num_loglevel_strings)
965 LOG(log_warning, logtype_logger, "%s is not a valid log level", loglevel);
970 if ((typenum>=num_logtype_strings) || (levelnum>=num_loglevel_strings))
972 LOG(log_warning, logtype_logger, "sanity check failed: (%s:%d), (%s:%d)",
973 logtype, typenum, loglevel, levelnum);
977 /* is this a syslog setup or a filelog setup */
978 if (filename==NULL) /* must be syslog */
980 LOG(log_note, logtype_logger, "Doing syslog_setup(%d, %d, ...)", levelnum, typenum);
981 syslog_setup(levelnum, typenum,
982 (*logs)[0].display_options,
983 global_log_data.facility);
985 else /* this must be a filelog */
987 LOG(log_note, logtype_logger, "Doing log_setup(%s, %d, %d, ...)", filename, levelnum, typenum);
988 log_setup(filename, levelnum, typenum,
989 (*logs)[0].display_options);
992 #endif /* DISABLE_LOGGER */