Skip to main content

Lens - send debug payloads to the Lens desktop app and Lens Cloud

Project description

Lens for Python

Send debug payloads to the Lens desktop app and Lens Cloud from any Python project (Django, Flask, FastAPI or plain scripts). No dependencies, just the standard library.

Install

pip install lens-debug

Use

from lens_debug import lens

lens("hello", user)                 # send any values
lens([1, 2, 3]).label("my array")   # add a label
lens("careful").red()               # colour the entry
lens.clear()                        # clear the Lens window

Colours: red, green, blue, orange, purple, gray.

Lens Cloud (optional)

To send events straight to Lens Cloud, no desktop app required, set one environment variable:

LENS_PROJECT_KEY=your-project-key-from-lens-cloud

With a key set, events go to Lens Cloud at https://app.lensapp.eu by default. Set LENS_CLOUD_URL only to point at a self-hosted or local cloud (e.g. http://localhost:3000). You can also configure it in code:

lens.configure(key="your-project-key")  # cloud_url defaults to https://app.lensapp.eu

Channels

Lens sends to two channels, independently toggleable (default on):

LENS_LOCAL=false   # disable the desktop app -> cloud only
LENS_CLOUD=false   # disable the cloud -> desktop app only

Or in code: lens.configure(local=False) / lens.configure(cloud=False).

Each event also carries context (Python version, OS, hostname and detected framework) which shows up as tags in Lens Cloud.

Caught exceptions

try:
    risky()
except Exception as err:
    lens.exception(err)

The exception (with its stack trace) shows up in Lens and can be picked up by the built-in "Summarize errors" AI button.

Configuration

Lens listens on 127.0.0.1:23600 by default. Override it in code or via environment variables:

lens.configure(host="127.0.0.1", port=23600)
export LENS_HOST=127.0.0.1
export LENS_PORT=23600

Safety

Debugging never blocks or crashes your program: every payload is sent on a daemon thread and all transmission errors are swallowed silently. If the Lens app is not running, calls are simply no-ops.

MIT licensed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lens_debug-1.2.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lens_debug-1.2.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file lens_debug-1.2.0.tar.gz.

File metadata

  • Download URL: lens_debug-1.2.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lens_debug-1.2.0.tar.gz
Algorithm Hash digest
SHA256 00c98faf9e7981d294ef43e683b6defe5ed12b1a376d567089bdb88bbf3a0081
MD5 14fab56f45929893cb64ce71ac71888c
BLAKE2b-256 9c399407bf00e627f11f71e14622a146f82e57b588914018263fdde51e3eb1ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for lens_debug-1.2.0.tar.gz:

Publisher: release.yml on lensapp-eu/lens-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lens_debug-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: lens_debug-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lens_debug-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b53e11dbb561b9af45bb26f1afe054238a9659a32a6d5720eeea517a55e00bf
MD5 bba62a38928a594a53b462842275d43f
BLAKE2b-256 f788acbdf89c69e081e669c45c946514070080f51cd581fc80f83b84d261660c

See more details on using hashes here.

Provenance

The following attestation bundles were made for lens_debug-1.2.0-py3-none-any.whl:

Publisher: release.yml on lensapp-eu/lens-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page