Inline Scripts: Better Logging (was: First-class print() support.)
See original GitHub issueCurrently, the recommended way to do logging in inline scripts is context.log
. It would be nice if print()
would just work out of the box and log to the event log. Not sure what’s the best way to do this (override, print, redirect sys.stdout, …?), that needs some experimentation. 😃
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
How can we print line numbers to the log in java
I'm assuming that you are looking for the line number solely to support debugging. There are better ways. There are hackish ways to...
Read more >Your Guide to the Python print() Function
In this step-by-step tutorial, you'll learn about the print() function in Python and discover some of its lesser-known features.
Read more >Add support for inline JS/CSS with #attached - Drupal
Settings are the very first JS printed, before JS files. ... Indeed, you add more ga() calls in your inline JS. So what?...
Read more >first - CSS: Cascading Style Sheets - MDN Web Docs
The :first CSS pseudo-class, used with the @page at-rule, represents the first page of a printed document. (See :first-child for general ...
Read more >In-Depth Guide to Building a PowerShell Pipeline in Azure ...
Build your own custom PowerShell pipeline and learn how to run PowerShell scripts in Azure DevOps pipeline in this in-depth blog post.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Celery, for example, simply overrides
sys.stdout
/sys.stderr
to achieve this.See: https://github.com/celery/celery/blob/aee706ad5a743e3a51ed40f827bc02e61947902d/celery/app/log.py#L196
The situation has changed since this discussion. Scripts and built-in addons are now unified, and I’d like code in both contexts to be the same. I don’t want magic prints in our main codebase, so we should also discourage them in scripts. On balance, the “right thing” here is to intercept prints in inline scripts and turn them into WARNs in the logs.
I’m going to close this ticket, which has become a bit bloated, and open a concrete action ticket instead.