def _log_to_file(self, etype, source, msg='', target='', hostmask='', params=''):
        """Override `log()` if bot is not initialized with a database
        connection. Do not call this method directly.
        """
        today = datetime.utcnow()
        # TODO: Use self.locale['timezone'] for changing time
        date = today.strftime(self.locale['date_fmt'])
        time = today.strftime(self.locale['time_fmt'])
        datetime_s = today.strftime(self.locale['short_datetime_fmt'])
        datetime_l = today.strftime(self.locale['long_datetime_fmt'])
        
        if target == self.nickname and etype in ('privmsg', 'action'):
            target = source

        if etype in self.log_formats:
            file_path = os.path.expanduser(self.log_file.format(**locals()))
            file_dir = os.path.dirname(file_path)
            if not os.path.isdir(file_dir):
                os.makedirs(file_dir)

            line = self.log_formats[etype].format(**locals())
            with open(file_path, 'a') as log:
                log.write(line+'\n')
def _log_to_file ( self , etype , source , msg = '' , target = '' , hostmask = '' , params = '' ) : today = datetime . utcnow ( ) date = today . strftime ( self . locale [ 'date_fmt' ] ) time = today . strftime ( self . locale [ 'time_fmt' ] ) datetime_s = today . strftime ( self . locale [ 'short_datetime_fmt' ] ) datetime_l = today . strftime ( self . locale [ 'long_datetime_fmt' ] ) if target == self . nickname and etype in ( 'privmsg' , 'action' ) : target = source if etype in self . log_formats : file_path = os . path . expanduser ( self . log_file . format ( ** locals ( ) ) ) file_dir = os . path . dirname ( file_path ) if not os . path . isdir ( file_dir ) : os . makedirs ( file_dir ) line = self . log_formats [ etype ] . format ( ** locals ( ) ) with open ( file_path , 'a' ) as log : log . write ( line + '\n' )
Override `log()` if bot is not initialized with a database
        connection. Do not call this method directly.