Skip to main content

termlog v1.2.1: A terminal logging library

Project description

Termlog

http://img.shields.io/badge/license-MIT-brightgreen.svg https://badge.fury.io/py/termlog.svg https://travis-ci.org/brianbruggeman/termlog.svg https://codecov.io/gh/brianbruggeman/termlog/branch/develop/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.

Source Distribution

termlog-1.2.1.tar.gz (30.6 kB view details)

Uploaded Source

File details

Details for the file termlog-1.2.1.tar.gz.

File metadata

  • Download URL: termlog-1.2.1.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.1

File hashes

Hashes for termlog-1.2.1.tar.gz
Algorithm Hash digest
SHA256 3a7ff849e2c2b940df036de7e99a368ad02dc237e6b44e485126c71a5b373df8
MD5 465999562ae809ef58edb8b6e3120f5e
BLAKE2b-256 f76f89399f1739eb016e9a3005e01b9278d32de2ece3e4384638672dc7b8a078

See more details on using hashes here.

Supported by

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