Skip to main content

Prepare lines of text for easy consumption

Project description

https://img.shields.io/badge/License-BSD%203--Clause-blue.svg https://travis-ci.com/tonysyu/linecook.svg?branch=master https://codecov.io/gh/tonysyu/linecook/branch/master/graph/badge.svg https://readthedocs.org/projects/linecook/badge/

linecook is a command-line tool that transforms lines of text into a form that’s pleasant to consume.

Install

The recommended way of installing linecook is to use pip:

pip install linecook

Cooking up some beautiful text

The core goal of linecook is to make it easy to create your own transforms to parse whatever text you have. For example, take an app.log file that looks like:

docs/_static/images/app_log_raw.png

If you want to highlight the log type and mute the dates/times, then you can create a custom recipe in one of your configuration files like the following:

from linecook import patterns as rx
from linecook.transforms import color_text

LINECOOK_CONFIG = {
    'recipes': {
        'my-logs': [
             color_text(rx.any_of(rx.date, rx.time), color='blue'),
             color_text('INFO', color='cyan'),
             color_text('WARN', color='grey', on_color='on_yellow'),
             color_text('ERROR', on_color='on_red'),
        ],
    },
}

To use this recipe, you can just pipe the log output to linecook with your new recipe as an argument:

docs/_static/images/app_log_linecook.png

That’s all there is to it!

See Also

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 linecook, version 0.4.0
Filename, size File type Python version Upload date Hashes
Filename, size linecook-0.4.0-py2.py3-none-any.whl (18.9 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size linecook-0.4.0.tar.gz (14.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page