/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }