-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
RFC: add logger that logs into browser console #4702
RFC: add logger that logs into browser console #4702
Conversation
|
||
|
||
def console_log_run(app, port, use_reloader): | ||
from console_log import ConsoleLog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put these imports at the top
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know imports should be top-level, but these are optional requirements (see the modified setup.py
). If they were in the top-level the CLI we would force everybody to install console_log
(and its dependencies: gevent
, gevent-websocket
, etc.).
🚢 |
Codecov Report
@@ Coverage Diff @@
## master #4702 +/- ##
==========================================
- Coverage 72.39% 72.33% -0.07%
==========================================
Files 208 208
Lines 15548 15568 +20
Branches 1204 1204
==========================================
+ Hits 11256 11261 +5
- Misses 4289 4304 +15
Partials 3 3
Continue to review full report at Codecov.
|
LGTM but it could use a description in CONTRIBUTING.md ! |
|
||
from superset import app | ||
app.logger.error('An exception occurred!') | ||
app.logger.info(form_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh does logging.debug('Foo')
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me give it a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mistercrunch, currently it won't work because console_log
adds the websocket handler to a single logger instance — Flask uses it's own (flask.app
), and it's different from the root logger. I'll modify the library so that it takes more than one logger instance, should be straightforward.
@@ -745,8 +745,10 @@ def shortner(self): | |||
obj = models.Url(url=url) | |||
db.session.add(obj) | |||
db.session.commit() | |||
return('http://{request.headers[Host]}/{directory}?r={obj.id}'.format( | |||
request=request, directory=directory, obj=obj)) | |||
return Response( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious on the angle here, you prefer an explicit Response
object?
LGTM |
Merge conflicts :( |
…ubator-superset into DPTOOLS-392_surface_granularity
* Option for logging into browser console * Move import * Add lint req * Add docs, use Flask logger
* Option for logging into browser console * Move import * Add lint req * Add docs, use Flask logger
* Option for logging into browser console * Move import * Add lint req * Add docs, use Flask logger
This PR integrates the console_log module with Superset, allowing records to be logged directly into the browser console in realtime. It adds a new option to the CLI,
--console-log
, which enables debug mode and creates a new root logger called "console".Demo
I temporarily added the following logging code:
Note how the Pandas data frame is logged as if it were printed in Python (using the
repr
function), and the form data is logged as a Javascript object, allowing it to be inspected.Notes
console_log
is based on gevent.gevent.monkey.patch_all()
, in order to make the Werkzeug code event based. Monkey patching is considered a bad practice in general, though gevent is pretty stable and its patching is pretty safe.-k "geventwebsocket.gunicorn.workers.GeventWebSocketWorker"
. In this PR the logging is only enabled in debug mode, nevertheless, since it's very experimental.I'm publishing this as an RFC since I understand these points might be controversial.