Exemplo n.º 1
0
    def __init__(self, mongo_url=None, verbose=False,
                 log_level='ERROR', log_config=None, log_file=None,
                 trace=False,
                 cache_enable=False,  
                 requests_cache_enable=None, requests_cache_path=None, 
                 requests_cache_expire=None,               
                 debug=False, silent=False, pretty=False, quiet=False):

        self.mongo_url = mongo_url
        self.verbose = verbose
        self.debug = debug
        self.silent = silent
        self.pretty = pretty
        self.quiet = quiet
        self.trace = trace
        
        self.cache_enable = cache_enable
        
        self.requests_cache_enable = requests_cache_enable
        self.requests_cache_path = requests_cache_path
        self.requests_cache_expire = requests_cache_expire
        
        self.log_level = log_level
        self.log_config = log_config
        self.log_file = log_file
        
        if self.verbose and log_level != "DEBUG":
            self.log_level = 'INFO'
        
        self.locker = None
        
        self.client_mongo = None
        self.db_mongo = None
        self.client_es = None
        self.fs_mongo = None
        
        self.logger = configure_logging(debug=self.debug, 
                                config_file=self.log_config, 
                                level=self.log_level)
        
        if self.log_file:
            self._set_log_file()
            
        if self.cache_enable:
            self._set_cache()
            
        if self.requests_cache_enable:
            self._set_requests_cache()
            
        if self.trace:
            from widukind_common import debug
            debug.TRACE_ENABLE = True
            atexit.register(debug.flush_logs)
Exemplo n.º 2
0
 def __init__(self, mongo_url=None, verbose=False,
              log_level='ERROR', log_config=None, 
              debug=False, silent=False, pretty=False):
     self.verbose = verbose
     self.debug = debug
     self.silent = silent
     self.pretty = pretty
     self.mongo_url = mongo_url
     
     self.log_level = log_level
     self.log_config = log_config
     
     if self.verbose:
         self.log_level = 'INFO'
     
     self.client_mongo = None
     self.db_mongo = None
     self.client_es = None
     self.fs_mongo = None
     
     self.logger = configure_logging(debug=self.debug, 
                             #stdout_enable, 
                             config_file=self.log_config, 
                             level=self.log_level)