Changeset 797


Ignore:
Timestamp:
03/07/11 12:49:44 (8 years ago)
Author:
aspidites
Message:

Patch by Aspidites:

  • converted print statements to logging messages.
  • all of parpg's log messages go to the same file, but are differenciated by their class names
  • need to find a way to manipulate fife's log level
Location:
branches/active/character_customization/game
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/active/character_customization/game/parpg/common/listeners/event_listener.py

    r736 r797  
    2020 
    2121from fife import fife 
     22import logging 
     23 
     24logger = logging.getLogger('event_listener') 
    2225 
    2326class EventListener(fife.IKeyListener,  
     
    5154                self.listeners[listener_type].append(listener)             
    5255        else: 
    53             print "Listener type \" " + listener_type + "\" not supported" 
     56            logger.warning("Listener type " 
     57                                  "'{0}' not supported".format(listener_type)) 
    5458     
    5559    def removeListener(self, listener_type, listener): 
     
    5862            self.listeners[listener_type].remove(listener) 
    5963        else: 
    60             print "Listener type \" " + listener_type + "\" not supported" 
     64            logger.warning("Listener type " 
     65                                  "'{0}' not supported".format(listener_type)) 
    6166             
    6267    def mousePressed(self, evt): 
  • branches/active/character_customization/game/parpg/dialogueactions.py

    r774 r797  
    1919import logging 
    2020 
    21 def setupLogging(): 
    22     """Set various logging parameters for this module.""" 
    23     module_logger = logging.getLogger('dialogueaction') 
    24     if __debug__: 
    25         module_logger.setLevel(logging.DEBUG) 
    26 setupLogging() 
     21logger = logging.getLogger('dialogueaction') 
    2722 
    2823class DialogueAction(object): 
  • branches/active/character_customization/game/parpg/dialogueparsers.py

    r774 r797  
    2525@TODO Technomage 2010-11-13: Support reading and writing unicode. 
    2626""" 
    27 import logging 
    2827try: 
    2928    from cStringIO import StringIO 
     
    4645from parpg.dialogueactions import DialogueAction 
    4746 
    48 def setup_logging(): 
    49     """Set various logging parameters for this module.""" 
    50     module_logger = logging.getLogger('dialogueparser') 
    51     if (__debug__): 
    52         module_logger.setLevel(logging.DEBUG) 
    53 setup_logging() 
     47import logging 
     48logger = logging.getLogger('dialogueparser') 
    5449 
    5550class DialogueFormatError(Exception): 
  • branches/active/character_customization/game/parpg/dialogueprocessor.py

    r774 r797  
    2525    from parpg.dialogue import Dialogue 
    2626 
    27 def setupLogging(): 
    28     """Set various logging parameters for this module.""" 
    29     module_logger = logging.getLogger('dialogueengine') 
    30     if (__debug__): 
    31         module_logger.setLevel(logging.DEBUG) 
    32 setupLogging() 
     27logger = logging.getLogger('dialogueprocessor') 
    3328 
    3429class DialogueProcessor(object): 
  • branches/active/character_customization/game/parpg/gamemodel.py

    r794 r797  
    3838 
    3939import yaml 
     40 
     41logger = logging.getLogger('gamemodel') 
    4042 
    4143class GameModel(object): 
     
    303305        @param position: X,Y coordinates passed from engine.changeMap 
    304306        @return: fife.Location""" 
    305         print position 
     307        logging.debug(position) 
    306308        coord = fife.DoublePoint3D(float(position[0]), float(position[1]), 0) 
    307309        location = fife.Location(self.active_map.agent_layer) 
     
    472474        map_obj = self.fife_model.getObject(str(object_id), "PARPG") 
    473475        if not map_obj: 
    474             print ''.join(['Object with inst_id=', str(object_id),  
    475                            ' ns=PARPG', \ 
    476                            ' could not be found. Omitting...']) 
     476            logging.warning("Object with inst_id={0}, ns=PARPG, " 
     477                                  "could not be found. " 
     478                                  "Omitting...".format(str(obj_id))) 
    477479 
    478480        x_pos = agent["Position"][0] 
     
    745747            except SyntaxError as error: 
    746748                assert(isinstance(error, SyntaxError)) 
    747                 print "Error parsing file " + xml_file + ": " + error.msg 
    748                 #TODO: We may want to make this an fatal error later. 
     749                logging.critical("Error parsing file {0}: " 
     750                                       "{1}".format(xml_file, error.msg)) 
     751                sys.exit(1) 
    749752     
    750753    def getDialogues(self): 
  • branches/active/character_customization/game/parpg/gamescenecontroller.py

    r796 r797  
    3737    from gamemodel import GameModel 
    3838    from parpg import PARPGApplication 
     39 
     40import logging 
     41 
     42logger = logging.getLogger('gamescenecontroller') 
    3943 
    4044class GameSceneController(ControllerBase): 
     
    136140                                           datetime.now().strftime( 
    137141                                           '%Y-%m-%d-%H-%M-%S'))) 
    138             print "PARPG: Saved:", screenshot_file 
    139142            self.engine.getRenderBackend().captureScreen(screenshot_file) 
     143            logger.info("PARPG: Saved: {0}".format(screenshot_file)) 
    140144        if(key_val == key.F10): 
    141145            # F10 shows/hides the console 
     
    314318    def nullFunc(self, userdata): 
    315319        """Sample callback for the context menus.""" 
    316         print userdata     
     320        logger.info(userdata) 
    317321 
    318322    def initTalk(self, npc_info): 
  • branches/active/character_customization/game/parpg/gui/dialoguegui.py

    r774 r797  
    2121from parpg.dialogueprocessor import DialogueProcessor 
    2222 
    23 def setupLogging(): 
    24     """Set various logging parameters for this module.""" 
    25     module_logger = logging.getLogger('dialoguegui') 
    26     if (__debug__): 
    27         module_logger.setLevel(logging.DEBUG) 
    28 setupLogging() 
     23logger = logging.getLogger('dialoguegui') 
    2924 
    3025class DialogueGUI(object): 
  • branches/active/character_customization/game/parpg/gui/filebrowser.py

    r774 r797  
    1616 
    1717import sys 
     18import logging 
     19 
     20logger = logging.getLogger('filebrowser') 
    1821 
    1922def u2s(string): 
     
    9396                except: 
    9497                    new_list.append(unicode(i, fs_encoding, 'replace')) 
    95                     print "WARNING: Could not decode item:", i 
     98                    logger.debug("WARNING: Could not decode item:\n" 
     99                                        "{0}".format(i)) 
    96100            return new_list 
    97101             
     
    139143            return 
    140144 
    141         print 'FileBrowser: error, no selection.' 
     145        logger.error('no selection') 
    142146 
    143147    def _warningMessage(self): 
  • branches/active/character_customization/game/parpg/gui/hud.py

    r796 r797  
    2525from parpg.gui import drag_drop_data as data_drag 
    2626from actionsbox import ActionsBox 
     27 
     28import logging 
     29 
     30logger = logging.getLogger('hud') 
    2731 
    2832class Hud(object): 
     
    298302           @return: None""" 
    299303        self.stopActions() 
    300         print 'new game' 
     304        logger.info('new game') 
    301305     
    302306    def loadsave_close(self): 
     
    445449                element.text = str(value) 
    446450        else: 
    447             print 'Setting,', name, 'does not exist!' 
     451            logger.warning("setting, {0} does not exist!".format(name)) 
    448452     
    449453    def readyAction(self, ready_button): 
  • branches/active/character_customization/game/parpg/gui/inventorygui.py

    r736 r797  
    2424from parpg.gui.containergui_base import ContainerGUIBase 
    2525from parpg.objects.action import ACTIONS 
     26 
     27import logging 
     28 
     29logger = logging.getLogger('action') 
    2630 
    2731class EquipmentSlot(pychan.VBox): 
     
    333337                data_drag.dragging = False 
    334338        except Container.TooBig : 
    335             print("%s too big to fit into %s" % (data_drag.dragged_item, 
    336                                                  drop_widget.slot)) 
     339            logger.warning("%s too big to fit " 
     340                                 "into %s" % (data_drag.dragged_item, 
     341                                              drop_widget.slot)) 
    337342        except (Container.SlotBusy, Container.ItemSelf): 
    338343            pass 
  • branches/active/character_customization/game/parpg/objects/action.py

    r774 r797  
    1515 
    1616#exceptions 
     17 
     18import logging 
     19 
     20logger = logging.getLogger('action') 
    1721 
    1822from parpg.gui import drag_drop_data as data_drag 
     
    201205        action_text = self.examine_desc 
    202206        self.view.hud.addAction(unicode(action_text)) 
    203         print action_text 
     207        logger.debug(action_text) 
    204208        #this code will cut the line up into smaller lines that will be displayed 
    205209        place = 25 
     
    235239        action_text = unicode(self.examine_desc) 
    236240        self.view.hud.addAction(action_text) 
    237         print action_text 
     241        logger.debug(action_text) 
    238242 
    239243class ReadAction(Action): 
     
    262266                                         self.text])) 
    263267        self.view.hud.addAction(action_text) 
    264         print action_text 
     268        logger.debug(action_text) 
    265269        super(ReadAction, self).execute() 
    266270 
  • branches/active/character_customization/game/parpg/serializers.py

    r774 r797  
    2828 
    2929from .common.utils import dedent_chomp 
     30 
     31import logging 
     32 
     33logger = logging.getLogger('serializers') 
    3034 
    3135class Serializable(object): 
     
    107111            object_ = class_(**init_args) 
    108112        except (TypeError, ValueError) as exception: 
    109             print(init_args) 
     113            logger.error(init_args) 
    110114            error_message = \ 
    111115                'unable to deserialize tag {0}: {1}'.format(element_name, 
  • branches/active/character_customization/game/parpg_editor.py

    r674 r797  
    3232 
    3333        args.append(os.path.join('..', parpg_dir, map_path)) 
    34         print args 
    3534 
    3635    fife_editor_path = os.path.join(parpg_path, '..', 'tools', 'map_editor') 
Note: See TracChangeset for help on using the changeset viewer.