Compare commits

...

3 Commits

Author SHA1 Message Date
Joe S cc0f6f9f9e Clean up logging in handler.py 2021-02-22 23:48:33 -05:00
Joe S 0c1770ef0a add some extra verbose logging to __main__ 2021-02-22 23:48:20 -05:00
Joe S 87fdc6b91e Add log to gitignore 2021-02-22 23:48:07 -05:00
3 changed files with 15 additions and 7 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.pyc *.pyc
.idea .idea
Adventure Game/adventure_game/logs/AdventureGame.log

View File

@ -9,8 +9,10 @@ class Handler(npyscreen.ButtonPress):
3: re-render the screen 3: re-render the screen
""" """
def whenPressed(self): def whenPressed(self):
self.parent.parentApp.log.debug('Send button pressed!')
# This is the raw command from the user # This is the raw command from the user
raw_command = self.parent.dialogueBox.value raw_command = self.parent.dialogueBox.value
self.parent.dialogueBox.value = '' # Clear the dialogue box, TODO: This may become unneeded if issue #8 is fixed
# This is the raw command from the user # This is the raw command from the user
parsed_command = raw_command.split() parsed_command = raw_command.split()
@ -18,11 +20,12 @@ class Handler(npyscreen.ButtonPress):
try: try:
command = parsed_command.pop(0) command = parsed_command.pop(0)
except IndexError: except IndexError:
pass self.parent.parentApp.log.warn('Command "{0}" could not be split, was it malformed or incomplete?'.format(raw_command))
arguments = parsed_command command = ''
arguments = parsed_command # Whatever is left in the list, are arguments.
self.parent.parentApp.log.info('Parsed command "{0}" with arguments "{1}"'.format(command, arguments))
self.parent.update_log('command: ' + command) self.parent.update_log('command: ' + command)
self.parent.update_log('args: {0}'.format(arguments)) self.parent.update_log('args: {0}'.format(arguments))
self.parent.dialogueBox.value = ''
self.parent.artContent.display() self.parent.artContent.display()
self.parent.parentApp.switchForm('GAME') self.parent.parentApp.switchForm('GAME')

View File

@ -31,11 +31,15 @@ class AdventureGame(npyscreen.NPSAppManaged):
# Setup logging # Setup logging
self.log = logging self.log = logging
self.log.basicConfig(filename=self.mainPath / 'logs/AdventureGame.log', filemode='w', level=logging.DEBUG) self.log.basicConfig(filename=self.mainPath / 'logs/AdventureGame.log',
filemode='w',
level=logging.DEBUG)
self.log.info('Logging started!')
# Parse world # parse this data first (since it includes graphics for the main menu
self.gamelib = parse( self.gamelib = parse(
self.mainPath / 'gamedata/gamelib.yaml') # parse this data first (since it includes graphics for the main menu self.mainPath / 'gamedata/gamelib.yaml')
self.log.debug('Gamelib at {0}'.format(self.mainPath / 'gamedata/gamelib.yaml'))
# Intalize the player as none, the player will be created in the main menu. # Intalize the player as none, the player will be created in the main menu.
self.player = None self.player = None