Ejemplo n.º 1
0
int logfflush(Log *l)
{
	int r = 0;

	if (!l)
		for (l = logroot; l; l = l->next) {
			if (stolen_logfile(l) && logfile_reopen(l->name, fileno(l->fp), l))
				return -1;
			r |= fflush(l->fp);
			l->flushcount++;
			changed_logfile(l);
	} else {
		if (stolen_logfile(l) && logfile_reopen(l->name, fileno(l->fp), l))
			return -1;
		r = fflush(l->fp);
		l->flushcount++;
		changed_logfile(l);
	}
	return r;
}
Ejemplo n.º 2
0
static void logit(int priority, const char *buf)
{
	if (logfile_was_closed)
		logfile_reopen();
	if (logfile_fp) {
		fprintf(logfile_fp, "%s [%d] %s", timestring(time(NULL)), (int)getpid(), buf);
		fflush(logfile_fp);
	} else {
		syslog(priority, "%s", buf);
	}
}
Ejemplo n.º 3
0
/*
 * XXX
 * write and flush both *should* check the file's stat, if it disappeared
 * or changed, re-open it.
 */
int logfwrite(Log *l, char *buf, size_t n)
{
	int r;

	if (stolen_logfile(l) && logfile_reopen(l->name, fileno(l->fp), l))
		return -1;
	r = fwrite(buf, n, 1, l->fp);
	l->writecount += l->flushcount + 1;
	l->flushcount = 0;
	changed_logfile(l);
	return r;
}