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
260
261
262
263
264
265

266
267
268
269
270
271
272
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273







+







#ifdef FILED_DONT_LOG
#  define filed_logging_thread_init(x) 0
#  define filed_log_msg_debug(x, ...) /**/
#  define filed_log_msg(x, ...) /**/
#  define filed_log_entry(x) /**/
#  define filed_log_ip(x, ...) NULL
#  define filed_log_new(x) &local_dummy_log
#  define filed_log_open(x) stdout
#else
#  ifdef FILED_DEBUG
#    define filed_log_msg_debug(x, ...) { fprintf(stderr, x, __VA_ARGS__); fprintf(stderr, "\n"); fflush(stderr); }
#  else
#    define filed_log_msg_debug(x, ...) /**/
#  endif

423
424
425
426
427
428
429












430
431
432
433
434
435
436
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449







+
+
+
+
+
+
+
+
+
+
+
+







			addr_v4 = (struct sockaddr_in *) addr;
			retval = inet_ntop(AF_INET, &addr_v4->sin_addr, buffer, bufferlen);
			break;
		case AF_INET6:
			retval = inet_ntop(AF_INET6, &addr_v6->sin6_addr, buffer, bufferlen);
			break;
	}

	return(retval);
}

static FILE *filed_log_open(const char *file) {
	FILE *retval;

	if (strcmp(file, "-") == 0) {
		retval = stdout;
	} else {
		retval = fopen(file, "a+");
	}

	return(retval);
}

static int filed_logging_thread_init(FILE *logfp) {
	struct filed_logging_thread_args *args;
	pthread_t thread_id;
1271
1272
1273
1274
1275
1276
1277
1278
1279

1280
1281
1282
1283


1284
1285

1286
1287
1288
1289
1290
1291
1292
1293
1284
1285
1286
1287
1288
1289
1290


1291




1292
1293
1294

1295

1296
1297
1298
1299
1300
1301
1302







-
-
+
-
-
-
-
+
+

-
+
-







				filed_print_help(stdout, 1, NULL);

				return(0);
		}
	}

	/* Open log file */
	if (strcmp(log_file, "-") == 0) {
		log_fp = stdout;
	log_fp = filed_log_open(log_file);
	} else {
		log_fp = fopen(log_file, "a+");
		if (log_fp == NULL) {
			perror("fopen");
	if (log_fp == NULL) {
		perror("filed_log_open");

			return(4);
		return(4);
		}
	}

	/* Create listening socket */
	fd = filed_listen(bind_addr, port);
	if (fd < 0) {
		perror("filed_listen");