References:
Last active
April 8, 2023 22:01
-
-
Save LinuxIsCool/9015f7e32bbd7c0c3eb4776ce306f918 to your computer and use it in GitHub Desktop.
Convenient terminal logging for python panel app development.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from icecream import ic | |
ic("🌈") | |
ic("------------------------") | |
ic("Vyper Examples Panel App") | |
# Reference: https://github.com/gruns/icecream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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