Next / Previous / Contents / Shipman's homepage

11. Log.addLogFile(): Log to another file

logscan.py
# - - -   L o g . a d d L o g F i l e

    def addLogFile(self, logFileName):
        '''Add another logging destination.
        '''

If logFileName is a name we've seen before, do nothing—we don't want to overwrite the existing file. Otherwise, try to open it, then add it to self.__logMap.

logscan.py
        #-- 1 --
        if logFileName in self.__logMap:
            return

        #-- 2 --
        # [ if logFileName can be opened new for writing ->
        #     self.__logMap[logFileName]  :=  that file, so opened
        #   else -> raise IOError ]
        self.__logMap[logFileName] = open(logFileName, 'w')