예제 #1
0
파일: eerror.cpp 프로젝트: frankzh/enigma2
void eDebugNoNewLine(const char* fmt, ...)
{
	char buf[1024];
	char ncbuf[1024];
	va_list ap;
	va_start(ap, fmt);
	vsnprintf(buf, sizeof(buf), fmt, ap);
	va_end(ap);
	removeAnsiEsc(buf, ncbuf);
	singleLock s(DebugLock);
	logOutput(lvlDebug, std::string(ncbuf));
	if (logOutputConsole)
	{
		if(m_erroroutput && m_erroroutput->eErrorOutput::pipe_fd[1] && m_erroroutput->eErrorOutput::threadrunning)
		{
			int n;
			char obuf[1024];
			snprintf(obuf, sizeof(obuf), "%s", logOutputColors? buf : ncbuf);
			n=write(m_erroroutput->eErrorOutput::pipe_fd[1], obuf, strlen(obuf));
			if(n<0)
				fprintf(stderr, "[eerror] row %d error: %s\n", __LINE__,strerror(errno));
		}
		else
			fprintf(stderr, "%s", logOutputColors? buf : ncbuf);
	}
}
예제 #2
0
파일: eerror.cpp 프로젝트: resmas/enigma2
void _eWarning(const char *file, int line, const char *function, const char* fmt, ...)
{
	char timebuffer[32];
	char header[256];
	char buf[1024];
	char ncbuf[1024];
	printtime(timebuffer, sizeof(timebuffer));
	snprintf(header, sizeof(header), "%s %s:%d %s ", timebuffer, file, line, function);
	va_list ap;
	va_start(ap, fmt);
	vsnprintf(buf, sizeof(buf), fmt, ap);
	removeAnsiEsc(buf, ncbuf);
	va_end(ap);
	singleLock s(DebugLock);
	logOutput(lvlWarning, std::string(header) + std::string(ncbuf) + "\n");
	if (logOutputConsole)
	{
		if (!logOutputColors)
			fprintf(stderr, "%s%s", header, ncbuf);
		else
		{
			snprintf(header, sizeof(header),	\
				ANSI_BLINK ANSI_BYELLOW	"%s "	/*color of timestamp*/\
				ANSI_GREEN	"%s:%d "	/*color of filename and linenumber*/\
				ANSI_BGREEN	"%s "		/*color of functionname*/\
				ANSI_BWHITE			/*color of debugmessage*/\
				, timebuffer, file, line, function);
			fprintf(stderr, "%s%s\n"ANSI_RESET, header, buf);
		}
	}
}
예제 #3
0
파일: eerror.cpp 프로젝트: frankzh/enigma2
void _eWarning(const char *file, int line, const char *function, const char* fmt, ...)
{
	char timebuffer[32];
	char header[256];
	char buf[1024];
	char ncbuf[1024];
	printtime(timebuffer, sizeof(timebuffer));
	snprintf(header, sizeof(header), "%s [!W!] %s:%d %s ", timebuffer, file, line, function);
	va_list ap;
	va_start(ap, fmt);
	vsnprintf(buf, sizeof(buf), fmt, ap);
	removeAnsiEsc(buf, ncbuf);
	va_end(ap);
	singleLock s(DebugLock);
	logOutput(lvlWarning, std::string(header) + std::string(ncbuf) + "\n");
	if (logOutputConsole)
	{
		if (!logOutputColors)
		{
			if(m_erroroutput && m_erroroutput->eErrorOutput::pipe_fd[1] && m_erroroutput->eErrorOutput::threadrunning)
			{
				int n;
				char obuf[1024];
				snprintf(obuf, sizeof(obuf), "%s%s\n", header, ncbuf);
				n=write(m_erroroutput->eErrorOutput::pipe_fd[1], obuf, strlen(obuf));
				if(n<0)
					fprintf(stderr, "[eerror] row %d error: %s\n", __LINE__,strerror(errno));
			}
			else
				fprintf(stderr, "%s%s\n", header, ncbuf);
		}
		else
		{
			snprintf(header, sizeof(header),	\
						"%s"		/*newline*/
				ANSI_BYELLOW	"%s "	/*color of timestamp*/\
				ANSI_GREEN	"%s:%d "	/*color of filename and linenumber*/\
				ANSI_BGREEN	"%s "		/*color of functionname*/\
				ANSI_BWHITE			/*color of debugmessage*/\
				, inNoNewLine?"\n":"", timebuffer, file, line, function);
			if(m_erroroutput && m_erroroutput->eErrorOutput::pipe_fd[1] && m_erroroutput->eErrorOutput::threadrunning)
			{
				int n;
				char obuf[1024];
				snprintf(obuf, sizeof(obuf), "%s%s\n"ANSI_RESET, header, buf);
				n=write(m_erroroutput->eErrorOutput::pipe_fd[1], obuf, strlen(obuf));
				if(n<0)
					fprintf(stderr, "[eerror] row %d error: %s\n", __LINE__,strerror(errno));
			}
			else
				fprintf(stderr, "%s%s\n"ANSI_RESET, header, buf);
		}
	}
	inNoNewLine = false;
}
예제 #4
0
파일: eerror.cpp 프로젝트: resmas/enigma2
void eDebugNoNewLine(const char* fmt, ...)
{
	char buf[1024];
	char ncbuf[1024];
	va_list ap;
	va_start(ap, fmt);
	vsnprintf(buf, sizeof(buf), fmt, ap);
	va_end(ap);
	removeAnsiEsc(buf, ncbuf);
	singleLock s(DebugLock);
	logOutput(lvlDebug, std::string(ncbuf));
	if (logOutputConsole)
		fprintf(stderr, "%s", logOutputColors? buf : ncbuf);

}
예제 #5
0
파일: eerror.cpp 프로젝트: resmas/enigma2
void eDebugNoNewLineEnd(const char* fmt, ...)
{
	char buf[1024];
	char ncbuf[1024];
	va_list ap;
	va_start(ap, fmt);
	vsnprintf(buf, sizeof(buf), fmt, ap);
	va_end(ap);
	removeAnsiEsc(buf, ncbuf);
	singleLock s(DebugLock);
	logOutput(lvlDebug, std::string(ncbuf) + "\n");
	if (logOutputConsole)
	{
		if(!logOutputColors)
			fprintf(stderr, "%s\n", ncbuf);
		else
			fprintf(stderr, "%s\n"ANSI_RESET, buf);
	}
}
예제 #6
0
파일: eerror.cpp 프로젝트: resmas/enigma2
void ePythonOutput(const char *file, int line, const char *function, const char *string)
{
#ifdef DEBUG
	char timebuffer[32];
	char header[256];
	char buf[1024];
	char ncbuf[1024];
	bool is_alert = false;
	bool is_warning = false;

	if(strstr(file, "e2reactor.py") || strstr(file, "traceback.py"))
		is_alert = true;
	printtime(timebuffer, sizeof(timebuffer));
	snprintf(header, sizeof(header), "%s %s:%d %s ", timebuffer, file, line, function);
	snprintf(buf, sizeof(buf), "%s", string);
	removeAnsiEsc(buf, ncbuf);
	is_alert |= findToken(ncbuf, alertToken);
	if(!is_alert)
		is_warning = findToken(ncbuf, warningToken);
	singleLock s(DebugLock);
	logOutput(lvlWarning, std::string(header) + std::string(ncbuf));
	if (logOutputConsole)
	{
		if (!logOutputColors)
			fprintf(stderr, "%s%s", header, ncbuf);
		else
		{
			snprintf(header, sizeof(header),	\
						"%s%s "		/*color of timestamp*/\
				ANSI_CYAN	"%s:%d "	/*color of filename and linenumber*/\
				ANSI_BCYAN	"%s "		/*color of functionname*/\
				ANSI_BWHITE			/*color of debugmessage*/\
				, is_alert?ANSI_BRED:is_warning?ANSI_BYELLOW:ANSI_WHITE, timebuffer, file, line, function);
			fprintf(stderr, "%s%s"ANSI_RESET, header, buf);
		}
	}
#endif
}
예제 #7
0
파일: eerror.cpp 프로젝트: frankzh/enigma2
void ePythonOutput(const char *file, int line, const char *function, const char *string)
{
#ifdef DEBUG
	char flagstring[10];
	char timebuffer[32];
	char header[256];
	char buf[2*1024];
	char ncbuf[2*1024];
	bool is_alert = false;
	bool is_warning = false;

	printtime(timebuffer, sizeof(timebuffer));
	if(strstr(file, "e2reactor.py") || strstr(file, "traceback.py"))
		is_alert = true;
	snprintf(buf, sizeof(buf), "%s", string);
	removeAnsiEsc(buf, ncbuf);
	is_alert |= findToken(ncbuf, alertToken);
	if(!is_alert)
		is_warning = findToken(ncbuf, warningToken);

	if(is_alert)
		snprintf(flagstring, sizeof(flagstring), "%s", "{ E }");
	else if(is_warning)
		snprintf(flagstring, sizeof(flagstring), "%s", "{ W }");
	else
		snprintf(flagstring, sizeof(flagstring), "%s", "{   }");

	if(line)
		snprintf(header, sizeof(header), "%s %s %s:%d %s ", timebuffer, flagstring, file, line, function);
	else
	{
		snprintf(flagstring, sizeof(flagstring), "%s", "{ D }");
		snprintf(header, sizeof(header), "%s %s ", timebuffer, flagstring);
	}
	singleLock s(DebugLock);
	logOutput(lvlWarning, std::string(header) + std::string(ncbuf));
	if (logOutputConsole)
	{
		if (!logOutputColors)
		{
			if(m_erroroutput && m_erroroutput->eErrorOutput::pipe_fd[1] && m_erroroutput->eErrorOutput::threadrunning)
			{
				int n;
				char obuf[1024];
				snprintf(obuf, sizeof(obuf), "%s%s", header, ncbuf);
				n=write(m_erroroutput->eErrorOutput::pipe_fd[1], obuf, strlen(obuf));
				if(n<0)
					fprintf(stderr, "[eerror] row %d error: %s\n", __LINE__,strerror(errno));
			}
			else
				fprintf(stderr, "%s%s", header, ncbuf);
		}
		else
		{
			if(line)
			{
				snprintf(header, sizeof(header),	\
							"%s"		/*newline*/
							"%s%s "		/*color of timestamp*/\
					ANSI_CYAN	"%s:%d "	/*color of filename and linenumber*/\
					ANSI_BCYAN	"%s "		/*color of functionname*/\
					ANSI_BWHITE			/*color of debugmessage*/\
					, inNoNewLine?"\n":"", is_alert?ANSI_BRED:is_warning?ANSI_BYELLOW:ANSI_WHITE, timebuffer, file, line, function);
			}
			else
			{
				snprintf(header, sizeof(header),	\
							"%s"		/*newline*/
							"%s%s "		/*color of timestamp*/\
					ANSI_BWHITE			/*color of debugmessage*/\
					, inNoNewLine?"\n":"", ANSI_MAGENTA, timebuffer);
			}

			if(m_erroroutput && m_erroroutput->eErrorOutput::pipe_fd[1] && m_erroroutput->eErrorOutput::threadrunning)
			{
				int n;
				char obuf[1024];
				snprintf(obuf, sizeof(obuf), "%s%s"ANSI_RESET, header, buf);
				n=write(m_erroroutput->eErrorOutput::pipe_fd[1], obuf, strlen(obuf));
				if(n<0)
					fprintf(stderr, "[eerror] row %d error: %s\n", __LINE__,strerror(errno));
			}
			else
				fprintf(stderr, "%s%s"ANSI_RESET, header, buf);
		}
	}
#endif
	inNoNewLine = false;
}
예제 #8
0
파일: eerror.cpp 프로젝트: frankzh/enigma2
void _eDebugNoNewLineStart(const char *file, int line, const char *function, const char* fmt, ...)
{
	char flagstring[10];
	char timebuffer[32];
	char header[256];
	char buf[1024];
	char ncbuf[1024];
	bool is_alert = false;
	bool is_warning = false;

	printtime(timebuffer, sizeof(timebuffer));
	va_list ap;
	va_start(ap, fmt);
	vsnprintf(buf, sizeof(buf), fmt, ap);
	va_end(ap);
	removeAnsiEsc(buf, ncbuf);
	is_alert = findToken(ncbuf, alertToken);
	if(!is_alert)
		is_warning = findToken(ncbuf, warningToken);

	if(is_alert)
		snprintf(flagstring, sizeof(flagstring), "%s", "< E >");
	else if(is_warning)
		snprintf(flagstring, sizeof(flagstring), "%s", "< W >");
	else
		snprintf(flagstring, sizeof(flagstring), "%s", "<   >");

	snprintf(header, sizeof(header), "%s %s %s:%d %s ", timebuffer, flagstring, file, line, function);
	singleLock s(DebugLock);
	logOutput(lvlDebug, std::string(header) + std::string(ncbuf));
	if (logOutputConsole)
	{
		if (!logOutputColors)
		{
			if(m_erroroutput && m_erroroutput->eErrorOutput::pipe_fd[1] && m_erroroutput->eErrorOutput::threadrunning)
			{
				int n;
				char obuf[1024];
				snprintf(obuf, sizeof(obuf), "%s%s", header, ncbuf);
				n=write(m_erroroutput->eErrorOutput::pipe_fd[1], obuf, strlen(obuf));
				if(n<0)
					fprintf(stderr, "[eerror] row %d error: %s\n", __LINE__,strerror(errno));
			}
			else
				fprintf(stderr, "%s%s", header, ncbuf);
		}
		else
		{
			snprintf(header, sizeof(header),	\
				ANSI_WHITE	"%s%s "		/*color of timestamp*/\
				ANSI_GREEN	"%s:%d "	/*color of filename and linenumber*/\
				ANSI_BGREEN	"%s "		/*color of functionname*/\
				ANSI_BWHITE			/*color of debugmessage*/\
				, is_alert?ANSI_BRED:is_warning?ANSI_BYELLOW:ANSI_WHITE, timebuffer, file, line, function);
			if(m_erroroutput && m_erroroutput->eErrorOutput::pipe_fd[1] && m_erroroutput->eErrorOutput::threadrunning)
			{
				int n;
				char obuf[1024];
				snprintf(obuf, sizeof(obuf), "%s%s", header, buf);
				n=write(m_erroroutput->eErrorOutput::pipe_fd[1], obuf, strlen(obuf));
				if(n<0)
					fprintf(stderr, "[eerror] row %d error: %s\n", __LINE__,strerror(errno));
			}
			else
				fprintf(stderr, "%s%s", header, buf);
		}
	}
	inNoNewLine = true;
}