Ignore:
Timestamp:
Jul 19, 2018 6:12:03 AM (6 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
c0de493
Parents:
02e7d3a
git-author:
Torin Cooper-Bennun <40573959+tcbennun@…> (07/19/18 06:12:03)
git-committer:
Piotr Rozyczko <piotr.rozyczko@…> (07/19/18 06:12:03)
Message:

SASVIEW-957 logging changes (#158)

  • rework XStream to continue to write to stdout/stderr alongside redirection; make logging level setting consistent; make log configuration more consistent
  • rm XStream; QT signal in QtHandler? logging handler; only logs in Log Explorer (no stdout/stderr)
  • no need to change handler level
  • use QTextBrowser.append to facilitate auto-scrolling in the Log Explorer
  • modify logger unit test to reflect changes (passes)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Utilities/UnitTesting/SasviewLoggerTest.py

    r53c771e re4335ae  
    1111 
    1212# Local 
    13 from sas.qtgui.Utilities.SasviewLogger import XStream 
    1413from sas.qtgui.Utilities.SasviewLogger import QtHandler 
    1514 
     
    2322        """ 
    2423        self.logger = logging.getLogger(__name__) 
    25         handler = QtHandler() 
    26         handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) 
    27         self.logger.addHandler(handler) 
     24        self.handler = QtHandler() 
     25        self.handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) 
     26        self.logger.addHandler(self.handler) 
    2827        self.logger.setLevel(logging.DEBUG) 
    2928 
     
    3534        Test redirection of all levels of logging 
    3635        """ 
    37         # Attach the listeners 
    38         XStream.stderr().messageWritten.connect( self.outHandlerGui.insertPlainText ) 
    39         XStream.stdout().messageWritten.connect( self.outHandlerGui.insertPlainText ) 
     36        # Attach the listener 
     37        self.handler.messageWritten.connect(self.outHandlerGui.insertPlainText) 
    4038 
    4139        # Send the signals 
     
    4442        self.logger.warning('warning message') 
    4543        self.logger.error('error message') 
    46         sys.stdout.write('with stdout') 
    47         sys.stderr.write('with stderr') 
    4844 
    4945        out=self.outHandlerGui.toPlainText() 
     
    5450        self.assertIn('WARNING: warning message', out) 
    5551        self.assertIn('ERROR: error message', out) 
    56         self.assertIn('with stdout', out) 
    57         self.assertIn('with stderr', out) 
    5852 
    5953if __name__ == "__main__": 
Note: See TracChangeset for help on using the changeset viewer.