diff --git a/profile_bluesky/startup/instrument/__init__.py b/profile_bluesky/startup/instrument/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/profile_bluesky/startup/instrument/session_logs.py b/profile_bluesky/startup/instrument/session_logs.py new file mode 100644 index 0000000..0ee47ac --- /dev/null +++ b/profile_bluesky/startup/instrument/session_logs.py @@ -0,0 +1,32 @@ +""" +configure session logging +""" + +import logging +import stdlogpj + +_log_path = os.path.join(os.getcwd(), ".logs") +if not os.path.exists(_log_path): + os.mkdir(_log_path) +CONSOLE_IO_FILE = os.path.join(_log_path, "ipython_console.log") + +# start logging console to file +# https://ipython.org/ipython-doc/3/interactive/magics.html#magic-logstart +from IPython import get_ipython +_ipython = get_ipython() +# %logstart -o -t .ipython_console.log "rotate" +_ipython.magic(f"logstart -o -t {CONSOLE_IO_FILE} rotate") + +BYTE = 1 +kB = 1024 * BYTE +MB = 1024 * kB +logger = stdlogpj.standard_logging_setup( + "bluesky-session", + "ipython_logger", + maxBytes=1*MB, + backupCount=9) +logger.setLevel(logging.DEBUG) + +logger.info('#'*60 + " startup") +logger.info('logging started') +logger.info(f'logging level = {logger.level}') diff --git a/profile_bluesky/startup/instrument/utils/__init__.py b/profile_bluesky/startup/instrument/utils/__init__.py new file mode 100644 index 0000000..aac67c6 --- /dev/null +++ b/profile_bluesky/startup/instrument/utils/__init__.py @@ -0,0 +1 @@ +from .explorer import *