Skip to content
Snippets Groups Projects
elog.c 50.5 KiB
Newer Older
 * not available). Used before ereport/elog can be used
Bruce Momjian's avatar
Bruce Momjian committed
 * safely (memory context, GUC load etc)
Bruce Momjian's avatar
Bruce Momjian committed
	va_list		ap;

	va_start(ap, fmt);
#ifndef WIN32
	/* On Unix, we just fprintf to stderr */
	vfprintf(stderr, fmt, ap);
#else
Bruce Momjian's avatar
Bruce Momjian committed

	/*
	 * On Win32, we print to stderr if running on a console, or write to
	 * eventlog if running as a service
	 */
	if (pgwin32_is_service())	/* Running as a service */
Bruce Momjian's avatar
Bruce Momjian committed
		char		errbuf[2048];		/* Arbitrary size? */

		vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
		write_eventlog(EVENTLOG_ERROR_TYPE, errbuf);
	}
Bruce Momjian's avatar
Bruce Momjian committed
	else
		/* Not running as service, write to stderr */
		vfprintf(stderr, fmt, ap);
#endif
	va_end(ap);
}