Changeset 787


Ignore:
Timestamp:
03/06/11 20:33:57 (9 years ago)
Author:
aspidites
Message:

Patch by Aspidites:

  • added command line options to change logging level as well as

the output of that information

Location:
branches/active/character_customization/game
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/active/character_customization/game/run.py

    r786 r787  
    2626                    default='.', 
    2727                    help='One or more files to load settings from') 
     28parser.add_argument('-f', '--logfile', 
     29                    help='Name of log file to save to') 
     30parser.add_argument('-l', '--loglevel', default='info', 
     31                    help='desired output level for log file') 
    2832args = parser.parse_args() 
    2933 
    30 # initialize settigns 
     34# initialize settings 
    3135settings = Settings(paths=args.filenames) 
    3236 
     
    3741          'critical': logging.CRITICAL} 
    3842 
    39 log_file = settings.parpg.LogFile or 'parpg.log' 
    40 log_level = settings.parpg.LogLevel or 'critical' 
    41 logging.basicConfig(filename=log_file, level=levels[log_level]) 
     43#TODO: setup formating 
     44logging.basicConfig(filename=args.logfile, level=levels[args.loglevel]) 
     45logger = logging.getLogger('parpg') 
    4246 
    43 if settings.parpg.FifePath is not None: 
     47try: 
    4448    sys.path.insert(0, settings.parpg.FifePath) 
     49except AttributeError: 
     50    logger.warning('[parpg] section has no FifePath option') 
    4551 
    4652try: 
     
    5157except ImportError: 
    5258    #TODO: pay attention to which module actually failed 
    53     logging.critical("Could not import fife module. 'Please install fife or add " 
     59    logger.critical("Could not import fife module. Please install fife or add " 
    5460                     "'FifePath' to the [parpg] section of your settings file") 
    5561    sys.exit(1) 
     
    6066    psyco_available = True 
    6167except ImportError: 
    62     logging.warning('Psyco Acceleration unavailable') 
     68    logger.warning('Psyco Acceleration unavailable') 
    6369    psyco_available = False 
    6470 
     
    6672    if psyco_available: 
    6773        psyco.full() 
    68         logging.info('Psyco Acceleration enabled') 
     74        logger.info('Psyco Acceleration enabled') 
    6975    else: 
    70         logging.warning('Please install psyco before attempting to use it' 
     76        logger.warning('Please install psyco before attempting to use it' 
    7177                        'Psyco Acceleration disabled') 
    7278else: 
    73     logging.info('Psycho Acceleration disabled') 
     79    logger.info('Psycho Acceleration disabled') 
    7480 
    7581# run the game 
  • branches/active/character_customization/game/settings.ini

    r786 r787  
    2828 
    2929[parpg] 
    30 LogFile = parpg.log 
    31 LogLevel = debug 
    3230Map = Mall 
    3331ObjectDatabaseFile = objects/object_database.yaml 
Note: See TracChangeset for help on using the changeset viewer.