예제 #1
0
파일: errors.py 프로젝트: GNOME/sabayon
def errors_exit_with_fatal_exception (domain, log_config_filename):
    """Exits the program when a fatal exception has occurred.  First, this logs the
    current exception to the debug log.  Then, it dumps the debug log to stderr
    and exits the program with exit code util.EXIT_CODE_FATAL.

    @domain: name of debug log domain
    @log_config_filename:  File to mention in the debug log as the source for its configuration

    Return value: this function does not return, as it exits the program."""

    debuglog.debug_log (True, domain, "Fatal exception!  Exiting abnormally.")
    debuglog.debug_log_current_exception (domain)
    debuglog.debug_log_dump_to_file (log_config_filename, sys.stderr)
    sys.exit (util.EXIT_CODE_FATAL)
예제 #2
0
파일: errors.py 프로젝트: GNOME/sabayon
def errors_exit_helper_normally (log_config_filename):
    """Used only from helper programs for Sabayon.  First, this dumps the debug log
    to stderr.  Then, it exits the program with exit code utils.EXIT_CODE_NORMAL
    if there were no recoverable errors during its execution, or with
    utils.EXIT_CODE_RECOVERABLE if there were recoverable errors.

    @log_config_filename: File to mention in the debug log as the source for its configuration

    Return value: this function does not return, as it exits the program."""

    # We are a helper program, so we *always* dump the log, since
    # the caller program will know what to do with it:
    # "sabayon-session" will pass it on to the parent "sabayon";
    # xinitrc will log it to ~/.xsession-errors, etc.
    debuglog.debug_log_dump_to_file (log_config_filename, sys.stderr)

    if errors_have_recoverable_error ():
        sys.exit (util.EXIT_CODE_RECOVERABLE)
    else:
        sys.exit (util.EXIT_CODE_NORMAL)
예제 #3
0
import debuglog
import sys

debuglog.debug_log_load_configuration ("test-debug-log.conf")

for i in range (1000):
    is_milestone = (i % 10 == 0)

    m = i % 3
    if m == 0:
        domain = "foo"
    elif m == 1:
        domain = "bar"
    elif m == 2:
        domain = debuglog.DEBUG_LOG_DOMAIN_USER

    debuglog.debug_log (is_milestone, domain, "%s" % i)
    print "logged %s" % i

debuglog.debug_log_dump_to_file ("test-debug-log.conf",sys.stderr)