Example #1
0
File: log.c Project: ampimis/RtkGps
void 
log_no_thread (int whichlog, char *fmt, ...)
{
	char buf[BUFSIZE];
	va_list ap;
	char *logtime;
	int fd = get_log_fd (whichlog);


		va_start(ap, fmt);
		vsnprintf(buf, BUFSIZE, fmt, ap);
  
		logtime = get_log_time();

		if (strstr (buf, "%s") != NULL) {
			fprintf (stderr, "WARNING, write_log () called with '%%s' formatted string [%s]!", buf);
			logtime = get_log_time();
			return;
		}

		if (fd != -1) {
			if ((whichlog != ANDROID_LOG_VERBOSE) || (info.logfiledebuglevel > -1)) {
				fd_write (fd, "[%s] %s\n", logtime, buf);
			}
		}

		if (whichlog != ANDROID_LOG_VERBOSE)
		{
			free (logtime);
			va_end (ap);
			return;
		}

		if (running == SERVER_RUNNING) {
			printf("\r[%s] %s\n", logtime, buf);
			fflush(stdout);
		} else
			fprintf (stderr, "[%s] %s\n", logtime, buf);

		if (logtime)
			free(logtime);
		va_end (ap);

}
Example #2
0
/* Writes the one line status report to the log and the console if needed */
void status_write(server_info_t *infostruct)
{
	char *lt = get_log_time();

//	if (running == SERVER_RUNNING) info.num_clients = (unsigned long int) count_clients();

	android_log(ANDROID_LOG_VERBOSE, "Bandwidth:%fKB/s Sources:%ld Clients:%ld", info.bandwidth_usage, info.num_sources, info.num_clients);

	if (lt)
		free(lt);

}
Example #3
0
File: log.c Project: ampimis/RtkGps
void 
write_log (int whichlog, char *fmt, ...)
{
	char buf[BUFSIZE];
	va_list ap;
	char *logtime;
	mythread_t *mt = thread_check_created ();
	int fd = get_log_fd (whichlog);


		va_start(ap, fmt);
		vsnprintf(buf, BUFSIZE, fmt, ap);
  
		if (!mt)
			fprintf (stderr, "WARNING: No mt while outputting [%s]", buf);

		logtime = get_log_time();

		if (strstr (buf, "%s") != NULL) {
			fprintf (stderr, "WARNING, write_log () called with '%%s' formatted string [%s]!", buf);
			free (logtime);
			return;
		}

		if (mt && fd != -1) {
			if ((whichlog != ANDROID_LOG_VERBOSE) || (info.logfiledebuglevel > -1)) {
				fd_write (fd, "[%s] [%d:%s] %s\n", logtime, mt->id, nullcheck_string (mt->name), buf);
			}
		}

		if (whichlog != ANDROID_LOG_VERBOSE)
		{
			free (logtime);
			va_end (ap);
			return;
		}

		if (running == SERVER_RUNNING) {
			printf("\r[%s] %s\n", logtime, buf);
			fflush(stdout);
		} else
			fprintf (stderr, "[%s] %s\n", logtime, buf);

		if (logtime)
			free(logtime);
		va_end (ap);
	
}
Example #4
0
void write_log(server_info_t *info, char *fmt, ...)
{
	char buf[1024];
	va_list ap;
	char *logtime;

	va_start(ap, fmt);
#ifdef HAVE_VSNPRINTF
	vsnprintf(buf, 1024, fmt, ap);
#else
	vsprintf (buf, fmt, ap);
#endif

	logtime = get_log_time();
	fprintf(info->logfile, "[%s] %s\n", logtime, buf);
	fflush(info->logfile);
	printf("[%s] %s\n", logtime, buf);
}