aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-19 15:18:52 -0500
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-19 15:18:52 -0500
commitd5ff463d11a7ce38d9a2700eeeaed7c4189b5c26 (patch)
tree4fc272e830f697860e5214bab924dc0f9f2bd16f /examples
parent47957d5e786acf34253f8ab6760f8e41b2ba5c9f (diff)
downloadqolab-d5ff463d11a7ce38d9a2700eeeaed7c4189b5c26.tar.gz
qolab-d5ff463d11a7ce38d9a2700eeeaed7c4189b5c26.zip
adding logging to example
Diffstat (limited to 'examples')
-rw-r--r--examples/lock_eit.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/examples/lock_eit.py b/examples/lock_eit.py
index 6b52c50..7d92ab1 100644
--- a/examples/lock_eit.py
+++ b/examples/lock_eit.py
@@ -1,3 +1,7 @@
+import logging
+# this should be done before justpy is called or log formatter does not work
+logging.basicConfig(format='%(asctime)s %(levelname)8s %(name)s: %(message)s', datefmt='%m/%d/%Y %H:%M:%S')
+
import justpy as jp
import pyvisa
import numpy as np
@@ -14,6 +18,11 @@ from qolab.hardware.rf_generator import AgilentE8257D
from qolab.feedback import PID
from qolab.data import TraceSetSameX, TraceXY, Trace
+l = logging.getLogger('qolab.gui.web')
+l.setLevel(logging.INFO)
+logger = logging.getLogger('Magnetometer')
+logger.setLevel(logging.INFO)
+
def initLog():
errorTrace = Trace("error")
errorTrace.config['unit']='V'
@@ -86,7 +95,7 @@ async def main():
apparatus.gui_log = gui.QOLTimeLog(a=wp)
apparatus.gui_log.save_controls.getNextDataFile = apparatus.getNextDataFile
- print("testing")
+ logger.info("Accessing hardware")
rm = pyvisa.ResourceManager()
instr_scope=rm.open_resource('TCPIP::192.168.0.61::INSTR')
scope = SDS1104X(instr_scope)
@@ -114,7 +123,7 @@ async def main():
# apparatus.rfgen.setFreqFixed(freqZero)
- print('========== Initial lock ===========')
+ logger.info('========== Initial lock ===========')
apparatus.state = 'Initial lock'
update_webpage(apparatus=apparatus)
apparatus.gui_log.setTraces( initLog() )
@@ -124,7 +133,7 @@ async def main():
feedbackLoop(apparatus, nsteps=100)
)
- print('========= Long term lock ===========')
+ logger.info('========= Long term lock ===========')
apparatus.state = 'Long term lock'
update_webpage(apparatus=apparatus)
apparatus.gui_log.setTraces( initLog() )
@@ -138,7 +147,7 @@ async def main():
apparatus.gui_log.stop_tasks()
task_wp_update_loop.cancel()
- print("done")
+ logger.info("done")
return(apparatus)
def update_webpage(byWhom=None, apparatus=None):
@@ -162,6 +171,7 @@ async def jp_startup():
jp.run_task(main())
if __name__ == '__main__':
+ logger.info('========== Start up ===========')
wp = jp.WebPage(delete_flag=False)
apparatus = BasicInstrument()