示例#1
0
/**
 * egg_debug_set_console_mode:
 **/
static void
egg_debug_set_console_mode (guint console_code)
{
	gchar command[13];

	/* don't put extra commands into logs */
	if (!egg_debug_is_console ())
		return;

	/* Command is the control command to the terminal */
	g_snprintf (command, 13, "%c[%dm", 0x1B, console_code);
	printf ("%s", command);
}
示例#2
0
文件: egg-debug.c 项目: hughsie/gft
/**
 * egg_debug_init:
 * @debug: If we should print out verbose logging
 **/
void
egg_debug_init (gboolean debug)
{
	/* check if we are on console */
	if (isatty (fileno (stdout)) == 1)
		g_setenv (EGG_CONSOLE, "1", FALSE);
	else
		g_setenv (EGG_CONSOLE, "0", FALSE);
	if (debug)
		g_setenv (EGG_VERBOSE, "1", FALSE);
	else
		g_setenv (EGG_VERBOSE, "0", FALSE);
	egg_debug ("Verbose debugging %i (on console %i)%s", egg_debug_enabled (), egg_debug_is_console (), EGG_VERBOSE);
}
示例#3
0
/**
 * egg_warning_real:
 **/
void
egg_warning_real (const gchar *func, const gchar *file, const int line, const gchar *format, ...)
{
	va_list args;
	gchar *buffer = NULL;

	if (!egg_debug_is_verbose () && !egg_debug_filter_module (file) && !egg_debug_filter_function (func))
		return;

	va_start (args, format);
	g_vasprintf (&buffer, format, args);
	va_end (args);

	/* do extra stuff for a warning */
	if (!egg_debug_is_console ())
		printf ("*** WARNING ***\n");
	egg_debug_print_line (func, file, line, buffer, CONSOLE_RED);

	g_free (buffer);
}
示例#4
0
/**
 * egg_error_real:
 **/
void
egg_error_real (const gchar *func, const gchar *file, const int line, const gchar *format, ...)
{
	va_list args;
	gchar *buffer = NULL;

	va_start (args, format);
	g_vasprintf (&buffer, format, args);
	va_end (args);

	/* do extra stuff for a warning */
	if (!egg_debug_is_console ())
		printf ("*** ERROR ***\n");
	egg_debug_print_line (func, file, line, buffer, CONSOLE_RED);
	g_free (buffer);

	/* we want to fix this! */
	egg_debug_backtrace ();

	exit (1);
}