Skip to content

Instantly share code, notes, and snippets.

@LinuxIsCool
Last active April 8, 2023 22:01
Show Gist options
  • Save LinuxIsCool/9015f7e32bbd7c0c3eb4776ce306f918 to your computer and use it in GitHub Desktop.
Save LinuxIsCool/9015f7e32bbd7c0c3eb4776ce306f918 to your computer and use it in GitHub Desktop.
Convenient terminal logging for python panel app development.
from icecream import ic
ic("🌈")
ic("------------------------")
ic("Vyper Examples Panel App")
# Reference: https://github.com/gruns/icecream
import logging
import panel as pn
pn.extension()
pn.extension('terminal')
# Setting Up Logging to Terminal
terminal = pn.widgets.Terminal()
logger = logging.getLogger("terminal")
def set_debug_logging():
logger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler(terminal)
stream_handler.terminator = " \n"
formatter = logging.Formatter("%(asctime)s [%(levelname)s]: %(message)s")
stream_handler.setFormatter(formatter)
stream_handler.setLevel(logging.DEBUG)
logger.addHandler(stream_handler)
def test_debug_logging():
logger.info("🌈")
logger.info("------------------------")
logger.info("Examples Panel App")
logger.info("Logging Info Enabled")
set_debug_logging()
test_debug_logging()
# Reference: https://panel.holoviz.org/reference/widgets/Terminal.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment