Skip to content

link xterm widget to python logging module #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dfreeman06
Copy link

@dfreeman06 dfreeman06 commented Mar 20, 2020

Binder

Extending the base xterm widget to use python's logging module.

@bollwyvl
Copy link
Contributor

Thanks, this looks great.

Much lint:

src/wxyz/lab/widget_logger.py:9:1: F401 'pygments.formatters.HtmlFormatter' imported but unused
src/wxyz/lab/widget_logger.py:11:1: F401 'pygments.token.Keyword' imported but unused
src/wxyz/lab/widget_logger.py:11:1: F401 'pygments.token.Number' imported but unused
src/wxyz/lab/widget_logger.py:11:1: F401 'pygments.token.Operator' imported but unused
src/wxyz/lab/widget_logger.py:11:1: F401 'pygments.token.Other' imported but unused
src/wxyz/lab/widget_logger.py:11:1: F401 'pygments.token.Punctuation' imported but unused
src/wxyz/lab/widget_logger.py:11:1: F401 'pygments.token.Text' imported but unused
src/wxyz/lab/widget_logger.py:11:1: F401 'pygments.token.Whitespace' imported but unused
src/wxyz/lab/widget_logger.py:34:76: W291 trailing whitespace
src/wxyz/lab/widget_logger.py:76:17: F841 local variable 'drop_msg' is assigned to but never used
src/wxyz/lab/widget_logger.py:112:32: W605 invalid escape sequence '\('
src/wxyz/lab/widget_logger.py:112:35: W605 invalid escape sequence '\w'
src/wxyz/lab/widget_logger.py:112:39: W605 invalid escape sequence '\)'
src/wxyz/lab/widget_logger.py:125:89: E501 line too long (92 > 88 characters)

will look into it when i get a chance...

@bollwyvl
Copy link
Contributor

Behind that lint is yet more lint. Needs further investigation.

Some questions:

  • should the buffer construct just go directly into terminal itself?
    • if not, should it be a subclass of terminal, or would you imagine piping multiple logs into a single terminal?
  • should maxsize be a trait?
  • would all the pygments stuff be useful to widgetize?
  • are there ways to reuse existing pygments color enums, or support its "named" color schemes?

In the demo:

  • can we make a side-by-side panel of buttons next to a terminal that fires off different kinds of messages?
  • can it be made more "factory" like, to support being importnbable and embedded in large constructs?

@dfreeman06
Copy link
Author

I went ahead and moved the buffer to the Terminal class and expanded the demo so it should be more factory like and also demonstrate how to do some styling. Also you can pass in any of the named pygment styles either as a string or by their class. I am not sure about widgetizing the color formatter, but it might cleanup the expanded demo a bit.

I also am not sure about subclassing the terminal directly yet versus the current XStream shim... not sure what the impact to logging flexibility would be.

@bollwyvl
Copy link
Contributor

Checking on binder (also added link up top).

@@ -104,9 +107,45 @@ def data(self, content):
def send_line(self, line):
""" convenience wrapper around send
"""
self.send({"content": f"{line}\r\n"})
if self.active_terminals >= 1:
Copy link
Contributor

@bollwyvl bollwyvl Mar 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could just be if self.active_terminals...

@@ -104,9 +107,45 @@ def data(self, content):
def send_line(self, line):
""" convenience wrapper around send
"""
self.send({"content": f"{line}\r\n"})
if self.active_terminals >= 1:
self.send({"content": f"{line}\r\n"})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm.... how about buffering send?

@@ -2,6 +2,7 @@
"""
# pylint: disable=unused-argument,no-name-in-module,import-error
import re
import queue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder if we might want deque...

"\n",
" logger.debug(\"debug message\")\n",
" logger.info(\"info message\")\n",
" logger.warn(\"warn message\")\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning to avoid 🐷

@bollwyvl
Copy link
Contributor

Need to re-investigate this, as well as a drop-in ipywidgets.Output replacement...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants