Changeset 38beeab in sasview


Ignore:
Timestamp:
Apr 9, 2017 3:45:49 AM (8 years ago)
Author:
Ricardo Ferraz Leal <ricleal@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
797a2e8
Parents:
5af6f58
Message:

Logger is now a separate file

Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • run.py

    r64ca561 r38beeab  
    1414""" 
    1515 
    16 import os 
    17 import sys 
    1816import imp 
    1917import logging 
    2018import logging.config 
     19import os 
     20import sys 
     21from contextlib import contextmanager 
     22from os.path import join as joinpath 
     23from os.path import abspath, dirname 
    2124 
    22 from contextlib import contextmanager 
    23 from os.path import abspath, dirname, join as joinpath 
     25from sasview.logger_config import SetupLogger 
    2426 
     27l = SetupLogger(__name__) 
     28logger = l.config_development() 
    2529 
    26 LOGGER_CONFIG_FILE = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'sasview/logging.ini') 
    27 logging.config.fileConfig(LOGGER_CONFIG_FILE, disable_existing_loggers=True) 
    28 logger = logging.getLogger(__name__) 
    29  
    30 def update_all_logs_to_debug(logger): 
    31     ''' 
    32     This updates all loggers and respective handlers to DEBUG 
    33     ''' 
    34     for handler in logger.handlers or logger.parent.handlers: 
    35         handler.setLevel(logging.DEBUG) 
    36     for name,_ in logging.Logger.manager.loggerDict.items(): 
    37         logging.getLogger(name).setLevel(logging.DEBUG) 
    38          
    3930def addpath(path): 
    4031    """ 
     
    154145 
    155146if __name__ == "__main__": 
    156     update_all_logs_to_debug(logger) 
     147    logger.debug("Starting SASVIEW in debug mode.") 
    157148    prepare() 
    158149    from sas.sasview.sasview import run 
    159150    run() 
    160      
     151    logger.debug("Ending SASVIEW in debug mode.") 
  • sasview/logging.ini

    r64ca561 r38beeab  
    1616 
    1717[formatter_detailed] 
    18 format=%(asctime)s:%(name)s:%(levelname)s: %(lineno)d: %(message)s 
     18format=%(asctime)s : %(levelname)s : %(name)s: %(lineno)d: %(message)s 
    1919 
    2020############################################################################### 
     
    2727class=logging.StreamHandler 
    2828formatter=simple 
    29 level=INFO 
     29level=WARNING 
    3030args=tuple() 
    3131 
    3232[handler_log_file] 
    3333class=logging.FileHandler 
    34 level=INFO 
     34level=DEBUG 
    3535formatter=detailed 
    3636args=(os.path.join(os.path.expanduser("~"),'sasview.log'),"a") 
     
    4343 
    4444[logger_root] 
    45 level=INFO 
     45level=DEBUG 
    4646formatter=default 
    4747handlers=console,log_file 
     
    6060 
    6161[logger_sasgui] 
    62 level=INFO 
     62level=DEBUG 
    6363qualname=sas.sasgui 
    6464handlers=console,log_file 
  • sasview/sasview.py

    r5af6f58 r38beeab  
    1818import traceback 
    1919 
    20 logger = logging.getLogger(__name__) 
    21 if not logger.root.handlers: 
    22     # Scripts running under py2exe do not have a __file__ global. Detect this and use sys.argv[0] instead. 
    23     try: 
    24         LOGGER_CONFIG_FILE = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'logging.ini') 
    25     except NameError:  # We are the main py2exe script, not a module 
    26         LOGGER_CONFIG_FILE = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), 'logging.ini') 
    27     logging.config.fileConfig(LOGGER_CONFIG_FILE, disable_existing_loggers=False) 
    28     logging.captureWarnings(True) 
     20from logger_config import SetupLogger 
     21 
     22l = SetupLogger(__name__) 
     23logger = l.config_production() 
    2924 
    3025# Log the start of the session 
  • src/sas/sasgui/guiframe/gui_manager.py

    r49165488 r38beeab  
    7777    # clean all these module variables and put them into a config class 
    7878    # that can be passed by sasview.py. 
    79     logger.info(sys.executable) 
    80     logger.info(str(sys.argv)) 
     79    logger.debug(sys.executable) 
     80    logger.debug(str(sys.argv)) 
    8181    from sas import sasview as sasview 
    8282    app_path = os.path.dirname(sasview.__file__) 
    83     logger.info("Using application path: %s", app_path) 
     83    logger.debug("Using application path: %s", app_path) 
    8484    return app_path 
    8585 
     
    109109        if fObj is not None: 
    110110            fObj.close() 
    111     logger.info("GuiManager loaded %s/%s" % (path, file)) 
     111    logger.debug("GuiManager loaded %s/%s" % (path, file)) 
    112112    return config_module 
    113113 
     
    126126        # Didn't find local config, load the default 
    127127        import sas.sasgui.guiframe.config as config 
    128         logger.info("using default local_config") 
     128        logger.debug("using default local_config") 
    129129    else: 
    130         logger.info("found local_config in %s" % os.getcwd()) 
     130        logger.debug("found local_config in %s" % os.getcwd()) 
    131131else: 
    132     logger.info("found local_config in %s" % PATH_APP) 
     132    logger.debug("found local_config in %s" % PATH_APP) 
    133133 
    134134from sas.sasgui.guiframe.customdir import SetupCustom 
     
    139139    if custom_config is None: 
    140140        msgConfig = "Custom_config file was not imported" 
    141         logger.info(msgConfig) 
     141        logger.debug(msgConfig) 
    142142    else: 
    143         logger.info("using custom_config in %s" % os.getcwd()) 
     143        logger.debug("using custom_config in %s" % os.getcwd()) 
    144144else: 
    145     logger.info("using custom_config from %s" % c_conf_dir) 
     145    logger.debug("using custom_config from %s" % c_conf_dir) 
    146146 
    147147# read some constants from config 
     
    21562156        if response is not None: 
    21572157            try: 
    2158                 #  
    21592158                content = response.read().strip() 
    2160                 logger.info("Connected to www.sasview.org. Latest version: %s" 
    2161                              % (content)) 
     2159                logger.info("Connected to www.sasview.org. Latest version: %s", content) 
    21622160                version_info = json.loads(content) 
    21632161            except: 
Note: See TracChangeset for help on using the changeset viewer.