Пример #1
0
    def __init__(self, type='', log_file='', test=False):
        if type == self.DEST_FILE and log_file != '':
            log_file = os.path.abspath(log_file)
            #make sure we have a log directory
            dirname, filename = os.path.split(log_file)
            if not os.path.exists(dirname):
                os.makedirs(dirname)

            self._destination = self.DEST_FILE
            self._file_logger = logging.getLogger(__name__)
            hdlr = logging.FileHandler(log_file)
            hdlr.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(user)s %(message)s %(extended_info)s'))
            self._file_logger.addHandler(hdlr)
            self._file_logger.setLevel(logging.DEBUG)
        else:
            if not test :
                from mongodb import mongo
                self._db_logger = mongo.get_collection('logs') 
            else :
                from mongodb import test_mongo
                self._db_logger = test_mongo.get_collection('logs')
            self._destination = 'DB'
 def __init__(self):
     super(Users, self).__init__()
     self.collection = mongo.get_collection('users')