Check-in [5abd6e92c9]
Overview
Comment:Updated to create function for opening log file
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:5abd6e92c922766ce27e110dc89980eb499cd675
User & Date: rkeene on 2014-02-11 16:45:21
Other Links: manifest | tags
Context
2014-02-11
16:50
Updated to support logging to processes in addition to files check-in: 541136d097 user: rkeene tags: trunk
16:45
Updated to create function for opening log file check-in: 5abd6e92c9 user: rkeene tags: trunk
08:36
Corrected spelling error in comments check-in: 7f5706f719 user: rkeene tags: trunk
Changes

Modified filed.c from [81f8f85f74] to [efe5cb96e7].

   259    259   #ifdef FILED_DONT_LOG
   260    260   #  define filed_logging_thread_init(x) 0
   261    261   #  define filed_log_msg_debug(x, ...) /**/
   262    262   #  define filed_log_msg(x, ...) /**/
   263    263   #  define filed_log_entry(x) /**/
   264    264   #  define filed_log_ip(x, ...) NULL
   265    265   #  define filed_log_new(x) &local_dummy_log
          266  +#  define filed_log_open(x) stdout
   266    267   #else
   267    268   #  ifdef FILED_DEBUG
   268    269   #    define filed_log_msg_debug(x, ...) { fprintf(stderr, x, __VA_ARGS__); fprintf(stderr, "\n"); fflush(stderr); }
   269    270   #  else
   270    271   #    define filed_log_msg_debug(x, ...) /**/
   271    272   #  endif
   272    273   
................................................................................
   423    424   			addr_v4 = (struct sockaddr_in *) addr;
   424    425   			retval = inet_ntop(AF_INET, &addr_v4->sin_addr, buffer, bufferlen);
   425    426   			break;
   426    427   		case AF_INET6:
   427    428   			retval = inet_ntop(AF_INET6, &addr_v6->sin6_addr, buffer, bufferlen);
   428    429   			break;
   429    430   	}
          431  +
          432  +	return(retval);
          433  +}
          434  +
          435  +static FILE *filed_log_open(const char *file) {
          436  +	FILE *retval;
          437  +
          438  +	if (strcmp(file, "-") == 0) {
          439  +		retval = stdout;
          440  +	} else {
          441  +		retval = fopen(file, "a+");
          442  +	}
   430    443   
   431    444   	return(retval);
   432    445   }
   433    446   
   434    447   static int filed_logging_thread_init(FILE *logfp) {
   435    448   	struct filed_logging_thread_args *args;
   436    449   	pthread_t thread_id;
................................................................................
  1271   1284   				filed_print_help(stdout, 1, NULL);
  1272   1285   
  1273   1286   				return(0);
  1274   1287   		}
  1275   1288   	}
  1276   1289   
  1277   1290   	/* Open log file */
  1278         -	if (strcmp(log_file, "-") == 0) {
  1279         -		log_fp = stdout;
  1280         -	} else {
  1281         -		log_fp = fopen(log_file, "a+");
  1282         -		if (log_fp == NULL) {
  1283         -			perror("fopen");
         1291  +	log_fp = filed_log_open(log_file);
         1292  +	if (log_fp == NULL) {
         1293  +		perror("filed_log_open");
  1284   1294   
  1285         -			return(4);
  1286         -		}
         1295  +		return(4);
  1287   1296   	}
  1288   1297   
  1289   1298   	/* Create listening socket */
  1290   1299   	fd = filed_listen(bind_addr, port);
  1291   1300   	if (fd < 0) {
  1292   1301   		perror("filed_listen");
  1293   1302