Skip to main content

A Terminal logging library

Project description

Termlog

http://img.shields.io/badge/license-MIT-brightgreen.svg https://badge.fury.io/py/termlog.svg https://github.com/brianbruggeman/termlog/workflows/Latest%20Stable/badge.svg https://codecov.io/gh/brianbruggeman/termlog/branch/stable/graph/badge.svg?token=y6xPnPtcdc

Termlog: A terminal logging library for logging data both as lexed text or json

Motivation

I love f-strings and I wanted a method of displaying beautiful f-strings in command-line interfaces. However, I needed a way of simultaneously creating a developer friendly text log and producing structured text that could be interpreted by a log-shipper in a clustered environment.

Termlog will…

  • wrap print statements with a new method, echo
  • echo is fully compatible with print and is meant to be a drop-in replacement
  • echo can immediately control: color, json, timestamp, time-format outputs on each invocation
  • Alternatively, a set_config command can set the library to use a specific configuration for each subsequent call to echo

Usage

from termlog import blue, echo, red, rgb, set_config

key = 'abc'
value = 123

set_config(color=True, json=False)

echo(f'{red(key)}: {blue(value)}')
echo(f'{rgb(message=key, red=71, green=61, blue=139)}: {blue(value)}')
echo(f'{key}: {blue(value)}', color=True)

Installation

To install termlog, simply run the following.

$ pip install termlog

Project details


Download files

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

Files for termlog, version 1.4.0
Filename, size File type Python version Upload date Hashes
Filename, size termlog-1.4.0.tar.gz (19.9 kB) File type Source Python version None Upload date Hashes View
Filename, size termlog-1.4.0-py3-none-any.whl (24.6 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page