Skip to main content

Prism – Colourise log files (with ANSI characters codes)

Project description

A command line log colouriser utility.

Installation

From Python package index (Pypi):

(sudo) pip install logprism

or from Github:

(sudo) pip install watchdog # optional

git clone https://github.com/peterhil/prism.git

cd prism

(sudo) python setyp.py install

Dependencies

All dependencies can be installed with pip, usually by:

pip install some-package

Required (automatically handled by pip):

  • ordereddict (if using Python 2.6)

Optional (install manually with pip):

  • watchdog (watch files and directories with the -w option. Recommended for Python 2.x only – doesn’t work with Python 3)

Developers only:

  • pytest (test framework)

  • tox (continuous integration)

Usage examples

Colourise stdin:

tail -f /opt/local/var/log/couchdb/couch.log | prism

Grep some logs for messages with levels:

prism -g /var/log/*.log

Combine with grep command to find just specific levels:

grep -iE ‘(warn|error)’ /var/log/*.log | prism -g

Match multiple log levels per line:

prism -m /var/log/apache2/vhost*log

prism -m <(echo “Dribble me a debug or info lest I notice no create nor alter nor drop of your critical tables.”)

Watch for a whole directory of logs for changes (and new files):

prism -m -w /opt/local/var/log/nginx/

Some programs output normally to stderr, grab that output for prism:

python run.py 2>&1 | prism

Test

Run unit tests:

python setup.py test

Run continuous integration with tox (from an activated virtualenv, use tox -r to recreate CI envs):

tox

Todo

  • Show some tail lines when using -w: Make a line cache (count total lines with wc -l) from the end of the file using some blocksize.

    1. Can be done with readlines() first. Then seek and read blocksize bytes from len(file)-blocksize and update cache.

    2. Later enable ncurses scrolling for earlier lines?

    3. Show n lines by default (a screenful / filecount?)

Download files

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

Source Distribution

logprism-0.1.2.tar.gz (8.1 kB view details)

Uploaded Source

File details

Details for the file logprism-0.1.2.tar.gz.

File metadata

  • Download URL: logprism-0.1.2.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for logprism-0.1.2.tar.gz
Algorithm Hash digest
SHA256 db3a2db40d7236167fdd25d259cc813fa69320ac2ab6cc6c760800e5957fe3b1
MD5 2c7bc46577793b8277d21fdc04a99af5
BLAKE2b-256 19f56484fda130fb4f722b72c13c737db3343360f4e8a849411a215752cbdadf

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