Changeset 2495513 in sasview


Ignore:
Timestamp:
Jul 19, 2018 6:50:26 AM (5 weeks ago)
Author:
tcbennun
Branches:
ESS_GUI_iss957
Parents:
1309205b
Message:

add user config flag for disabling DEBUG logs

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • run.py

    r2e27cdb6 r2495513  
    150150    # so logging can be done during initialization process too 
    151151    root = abspath(dirname(realpath(sys.argv[0]))) 
    152     addpath(joinpath(root, 'src','sas')) 
    153     from logger_config import SetupLogger 
     152 
     153    addpath(joinpath(root, 'src')) 
     154    addpath(joinpath(root, '../sasmodels/')) # needed for custom_config to load 
     155 
     156    from sas.logger_config import SetupLogger 
    154157    logger = SetupLogger(__name__).config_development() 
    155158 
  • src/sas/logger_config.py

    r41d6187 r2495513  
    77 
    88import pkg_resources 
     9 
     10from sas import get_custom_config 
    911 
    1012''' 
     
    3941        logging.captureWarnings(True) 
    4042 
     43        self._disable_debug_from_config() 
     44 
    4145        return logger 
     46 
     47    def _disable_debug_from_config(self): 
     48        '''disable DEBUG logs as per user configuration (DEBUG logs disabled 
     49        by default)''' 
     50        disable_debug = True 
     51        custom_config = get_custom_config() 
     52 
     53        if hasattr(custom_config, "FILTER_DEBUG_LOGS"): 
     54            if type(custom_config.FILTER_DEBUG_LOGS) is bool: 
     55                disable_debug = custom_config.FILTER_DEBUG_LOGS 
     56            else: 
     57                logging.warning( 
     58                    "FILTER_DEBUG_LOGS has invalid value in custom_config.py" 
     59                ) 
     60 
     61        if disable_debug: 
     62            logging.info("disabling debug logs") 
     63            logging.disable(logging.DEBUG) 
    4264 
    4365    def _read_config_file(self): 
  • src/sas/sasview/custom_config.py

    r914ba0a r2495513  
    1616DEFAULT_PERSPECTIVE = "Fitting" 
    1717SAS_OPENCL = "None" 
     18 
     19# Logging options 
     20FILTER_DEBUG_LOGS = True 
Note: See TracChangeset for help on using the changeset viewer.