question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inline Scripts: Better Logging (was: First-class print() support.)

See original GitHub issue

Currently, 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:closed
  • Created 7 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
KostyaEsmukovcommented, May 14, 2016

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

0reactions
cortesicommented, Sep 4, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found