mirror of
https://github.com/gryf/fs-uae-wrapper.git
synced 2026-02-13 12:45:46 +01:00
Added logging module
This commit is contained in:
@@ -177,14 +177,34 @@ class Base(object):
|
||||
needed to calculate new paths so that emulator can find assets.
|
||||
"""
|
||||
exclude_list = ['save_states_dir']
|
||||
include_list = ['wrapper_archive', 'accelerator_rom', 'base_dir',
|
||||
'cdrom_drive_0', 'cdroms_dir', 'controllers_dir',
|
||||
'cpuboard_flash_ext_file', 'cpuboard_flash_file',
|
||||
'floppies_dir', 'floppy_overlays_dir', 'fmv_rom',
|
||||
'graphics_card_rom', 'hard_drives_dir',
|
||||
'kickstart_file', 'kickstarts_dir', 'logs_dir',
|
||||
'screenshots_output_dir', 'state_dir']
|
||||
for num in range(20):
|
||||
include_list.append('cdrom_image_%d' % num)
|
||||
include_list.append('floppy_image_%d' % num)
|
||||
|
||||
for num in range(4):
|
||||
include_list.append('floppy_drive_%d' % num)
|
||||
|
||||
for num in range(10):
|
||||
include_list.append('hard_drive_%d' % num)
|
||||
|
||||
conf_abs_dir = os.path.dirname(os.path.abspath(self.conf_file))
|
||||
changed_options = {}
|
||||
|
||||
for key, val in utils.get_config(self.conf_file).items():
|
||||
if val.startswith('/'):
|
||||
if key in exclude_list:
|
||||
continue
|
||||
|
||||
if key in exclude_list:
|
||||
if key not in include_list:
|
||||
continue
|
||||
|
||||
if val.startswith('/'):
|
||||
continue
|
||||
|
||||
if val.startswith('$CONFIG'):
|
||||
|
||||
@@ -4,6 +4,7 @@ Wrapper for FS-UAE to perform some actions before and or after running the
|
||||
emulator, if appropriate option is enabled.
|
||||
"""
|
||||
import importlib
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -11,6 +12,25 @@ from fs_uae_wrapper import utils
|
||||
from fs_uae_wrapper import WRAPPER_KEY
|
||||
|
||||
|
||||
def setup_logger(options):
|
||||
"""Setup logger format and level"""
|
||||
|
||||
level = logging.WARNING
|
||||
|
||||
if options['wrapper_quiet']:
|
||||
level = logging.ERROR
|
||||
if options['wrapper_quiet'] > 1:
|
||||
level = logging.CRITICAL
|
||||
|
||||
if options['wrapper_verbose']:
|
||||
level = logging.INFO
|
||||
if options['wrapper_verbose'] > 1:
|
||||
level = logging.DEBUG
|
||||
|
||||
logging.basicConfig(level=level,
|
||||
format="%(asctime)s %(levelname)s: %(message)s")
|
||||
|
||||
|
||||
def parse_args():
|
||||
"""
|
||||
Look out for config file and for config options which would be blindly
|
||||
@@ -18,7 +38,16 @@ def parse_args():
|
||||
"""
|
||||
fs_conf = None
|
||||
options = utils.CmdOption()
|
||||
options['wrapper_verbose'] = 0
|
||||
options['wrapper_quiet'] = 0
|
||||
|
||||
for parameter in sys.argv[1:]:
|
||||
if parameter in ['-v', '-q']:
|
||||
if parameter == '-v':
|
||||
options['wrapper_verbose'] += 1
|
||||
if parameter == '-q':
|
||||
options['wrapper_quiet'] += 1
|
||||
continue
|
||||
try:
|
||||
options.add(parameter)
|
||||
except AttributeError:
|
||||
@@ -47,6 +76,9 @@ def usage():
|
||||
def run():
|
||||
"""run wrapper module"""
|
||||
config_file, fsuae_options = parse_args()
|
||||
setup_logger(fsuae_options)
|
||||
del fsuae_options['wrapper_verbose']
|
||||
del fsuae_options['wrapper_quiet']
|
||||
|
||||
if 'help' in fsuae_options:
|
||||
usage()
|
||||
|
||||
Reference in New Issue
Block a user