Skip to main content

X(), for low level debugging

Project description

X(), for low level debugging

X() is my function for low level ad hoc debug messages. It takes a message and optional format arguments for use with %. It is presented here in its own module for reuse.

It normally writes directly to sys.stderr but accepts an optional keyword argument file to specify a different filelike object. If file is not specified, its behaviour is further tweaked with the globals X_discard, X_logger and X_via_tty: if X_logger then log a warning to that logger; otherwise if X_via_tty then open /dev/tty and write the message to it; otherwise if X_discard then discard the message; otherwise write the message to sys.stderr. X_discard's default value is not sys.stderr.isatty().

Function X(msg, *args, **kw)

Unconditionally write the message msg.

If there are positional arguments after msg, format msg using %-expansion with those arguments.

Keyword arguments:

  • file: optional keyword argument specifying the output file.
  • colour: optional text colour. If specified, surround the message with ANSI escape sequences to render the text in that colour.

If file is not None, write to it unconditionally; otherwise if X_logger then log a warning to that logger; otherwise if X_via_tty then open /dev/tty and write the message to it; otherwise if X_discard then discard the message; otherwise write the message to sys.stderr.

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

cs.x-20181231.tar.gz (2.7 kB view details)

Uploaded Source

File details

Details for the file cs.x-20181231.tar.gz.

File metadata

  • Download URL: cs.x-20181231.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.0 CPython/3.6.6

File hashes

Hashes for cs.x-20181231.tar.gz
Algorithm Hash digest
SHA256 2152e5db088184f05840554068674c2623df6638af8ed49a2b772a6a2beafff2
MD5 9527cf758ef65c435360d59f45bd2995
BLAKE2b-256 339017572123a0381e470986a36bcd87bad8962c8def3505bef58547956ea973

See more details on using hashes here.

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