コード例 #1
0
def output_error_log_file(arguments):
    #-- format: GRACE_mean_failed_run_2002-04-01_PID-70335.log
    args = (time.strftime('%Y-%m-%d',time.localtime()), os.getpid())
    LOGFILE = 'GRACE_mean_failed_run_{0}_PID-{1:d}.log'.format(*args)
    #-- create a unique log and open the log file
    DIRECTORY = os.path.expanduser(arguments.directory)
    fid = utilities.create_unique_file(os.path.join(DIRECTORY,LOGFILE))
    logging.basicConfig(stream=fid, level=logging.INFO)
    #-- print argument values sorted alphabetically
    logging.info('ARGUMENTS:')
    for arg, value in sorted(vars(arguments).items()):
        logging.info('{0}: {1}'.format(arg, value))
    #-- print traceback error
    logging.info('\n\nTRACEBACK ERROR:')
    traceback.print_exc(file=fid)
    #-- close the log file
    fid.close()
コード例 #2
0
def output_log_file(arguments, output_files):
    #-- format: GRACE_processing_run_2002-04-01_PID-70335.log
    args = (time.strftime('%Y-%m-%d', time.localtime()), os.getpid())
    LOGFILE = 'GRACE_processing_run_{0}_PID-{1:d}.log'.format(*args)
    #-- create a unique log and open the log file
    DIRECTORY = os.path.expanduser(arguments.output_directory)
    fid = utilities.create_unique_file(os.path.join(DIRECTORY, LOGFILE))
    logging.basicConfig(stream=fid, level=logging.INFO)
    #-- print argument values sorted alphabetically
    logging.info('ARGUMENTS:')
    for arg, value in sorted(vars(arguments).items()):
        logging.info('{0}: {1}'.format(arg, value))
    #-- print output files
    logging.info('\n\nOUTPUT FILES:')
    for f in output_files:
        logging.info('{0}'.format(f))
    #-- close the log file
    fid.close()