Skip to main content

C++ Style Colorful output stream for Python with debug level capabilities.

Project description

cstream

C/C++ Style Colorful output stream for Python with level control and thread/process safety options.



Installation

$ pip install cstream

Introduction

Default stderr, stdwar and stdlog instances are directed to standard error output. Note that stdout is also available.

The devnull stram is intended to be used as a context manager in order to supress output directed to stderr and stdout.

Verbosity level control is coherent with the logging module and its constants are made available form importing.

Examples

from cstream import CStream, stderr, stdout, stdlog, stdwar, devnull, WARNING

# Set debug level
CStream.config(level=WARNING)

# Will be printed
stderr << "Error: You are 'redly' wrong"

# Gets printed also
stdwar << "Warning: Just a 'yellowish' warning..."

# Bypassed
stdlog << "DEBUG: Some blue text printed to stderr"

# Suppress all output written to stdout and stderr
with devnull:
    print("Bye World?")

Threads and Multiprocessing

from cstream import CStream

# For usage within threads
CStream.config(lock_type=CStream.T_LOCK)

# For multiprocessing
CStream.config(lock_type=CStream.P_LOCK)

# When no lock is needed (Default)
CStream.config(lock_type=None)

Next steps:

  • Complete logging integration.
  • Thread-safe logging.

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

cstream-1.0.4.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

cstream-1.0.4-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

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