Skip to content

link xterm widget to python logging module#23

Open
dfreeman06 wants to merge 2 commits into
deathbeds:masterfrom
dfreeman06:xterm_logger
Open

link xterm widget to python logging module#23
dfreeman06 wants to merge 2 commits into
deathbeds:masterfrom
dfreeman06:xterm_logger

Conversation

@dfreeman06
Copy link
Copy Markdown

@dfreeman06 dfreeman06 commented Mar 20, 2020

Binder

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

@bollwyvl
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Checking on binder (also added link up top).

""" convenience wrapper around send
"""
self.send({"content": f"{line}\r\n"})
if self.active_terminals >= 1:
Copy link
Copy Markdown
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...

"""
self.send({"content": f"{line}\r\n"})
if self.active_terminals >= 1:
self.send({"content": f"{line}\r\n"})
Copy link
Copy Markdown
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?

"""
# pylint: disable=unused-argument,no-name-in-module,import-error
import re
import queue
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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