Changeset e61f668 in sasview


Ignore:
Timestamp:
Aug 18, 2017 10:49:56 AM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
7c64911
Parents:
12f7f24
Message:

make logger available to run.py functions even when not run as main

File:
1 edited

Legend:

Unmodified
Added
Removed
  • run.py

    r7df0ccd re61f668  
    2222from os.path import join as joinpath 
    2323from os.path import abspath, dirname 
    24  
    2524 
    2625def addpath(path): 
     
    157156        sas.sasview.__build__ = str(git_revision).strip() 
    158157    except subprocess.CalledProcessError as cpe: 
    159         logger.warning("Error while determining build number\n  Using command:\n %s \n Output:\n %s"% (cpe.cmd,cpe.output)) 
     158        get_logger().warning("Error while determining build number\n  Using command:\n %s \n Output:\n %s"% (cpe.cmd,cpe.output)) 
    160159 
     160_logger = None 
     161def get_logger(): 
     162    global _logger 
     163    if _logger is not None: 
     164        from sas.logger_config import SetupLogger 
     165        _logger = SetupLogger(__name__).config_development() 
     166    return _logger 
    161167 
    162168if __name__ == "__main__": 
     
    165171    root = abspath(dirname(__file__)) 
    166172    addpath(joinpath(root, 'src')) 
    167     from sas.logger_config import SetupLogger 
    168     logger = SetupLogger(__name__).config_development() 
    169173 
    170     logger.debug("Starting SASVIEW in debug mode.") 
     174    get_logger().debug("Starting SASVIEW in debug mode.") 
    171175    prepare() 
    172176    from sas.sasview.sasview import run_gui 
    173177    run_gui() 
    174     logger.debug("Ending SASVIEW in debug mode.") 
     178    get_logger().debug("Ending SASVIEW in debug mode.") 
Note: See TracChangeset for help on using the changeset viewer.