Scol (Stream Colorizer)

Overview

crates.io

Scol (Stream Colorizer)

Scol is a simple command-line program that reads lines from standard input and colorizes them based on a regular expression pattern. The program supports setting both foreground and background colors for the matched text, using command-line arguments.

Installation

To install the program, you'll need Rust and Cargo installed on your system. Then, run the following command:

cargo install scol

Usage

The program's basic usage is:

scol  [--fg ] [--bg ] [--ignore-case] [--only-matching]

where is a regular expression pattern that will be used to match lines, --fg sets the foreground color of the matched text (using one of the available colors: black, red, green, yellow, blue, cyan, white, magenta), --bg sets the background color of the matched text, and --ignore-case makes the pattern match case-insensitively.

At least one of --fg or --bg must be specified.

Here's an example command that colorizes all lines containing the word "error" in red text on a yellow background:

tail -f /var/log/syslog | scol error --fg red --bg yellow

Example

Suppose you have a log file that contains lines like this:

[2022-05-06 10:23:45] INFO: Connected to database
[2022-05-06 10:24:13] WARNING: Disk space running low
[2022-05-06 10:25:01] ERROR: Database connection lost
[2022-05-06 10:26:19] INFO: System shutting down

You can use Scol to highlight lines containing the word "error" in red text on a yellow background, and lines containing the word "warning" in yellow text on a red background, using the following commands:

cat logfile.txt | scol error --fg red --bg yellow | scol warning --fg yellow --bg red

The output would be:

[2022-05-06 10:23:45] INFO: Connected to database
[2022-05-06 10:24:13] WARNING: Disk space running low
[2022-05-06 10:25:01] ERROR: Database connection lost
[2022-05-06 10:26:19] INFO: System shutting down

where the "warning" line is highlighted in yellow on a red background, and the "error" line is highlighted in red on a yellow background.

License

This program is distributed under the MIT license. See the LICENSE file for details.

You might also like...
Rust SDK for working with RIS-Live real-time BGP data stream.
Rust SDK for working with RIS-Live real-time BGP data stream.

ris-live-rs Provides parsing functions for RIS-Live real-time BGP message stream JSON data. The main parsing function, parse_ris_live_message converts

SpringQL: Open-source stream processor for IoT devices and in-vehicle computers

What is SpringQL? SpringQL is an open-source stream processor specialized in memory efficiency. It is supposed to run on embedded systems like IoT dev

Random music in Annil and stream as a radio station.

anni-radio anni-radio is an audio streaming client for Project Anni. Installation cargo install --git https://github.com/project-anni/radio Dependency

A VtubeStudio plugin that allows iFacialMocap to stream data to the app, enabling full apple ARkit facial tracking to be used for 2D Vtuber models.

facelink_rs A VtubeStudio plugin that allows iFacialMocap to stream data to the app, enabling full apple ARkit facial tracking to be used for 2D Vtube

Stream-based FSEvents API bindings.

fsevent-stream Stream-based FSEvents API bindings. Features Support directory-granular and file-granular events. Retrieve related file inode with kFSE

Collection of stream cipher algorithms

RustCrypto: stream ciphers Collection of stream cipher algorithms written in pure Rust. ⚠️ Security Warning: Hazmat! Crates in this repository do not

Log agent to replay time-stamped log stream

replayman Log agent to replay time-stamped log stream. Getting started Installation cargo install replayman Prepare for your data TSV with a header li

A ffmpeg/rust based HLS stream generator
A ffmpeg/rust based HLS stream generator

hls-streamer Stream your heart's content with HLS. Movtivation I've got a CCTV camera from AliExpress, I know I can use ffmpeg hls demuxer to split up

Simple crate that wraps a tokio::process into a tokio::stream

tokio-process-stream tokio-process-stream is a simple crate that wraps a tokio::process into a tokio::stream Having a stream interface to processes is

Taggart's Intro to Rust Stream

mttaggFerris Taggart's Intro to Rust Stream 1/5/22 https://youtu.be/UWVBp5kpxFk Interesting tidbits: Rust binaries are (usually) statically compiled,

Test whether a given stream is a terminal

is-terminal Test whether a given stream is a terminal is-terminal is a simple utility that answers one question: Is this a terminal? A "terminal", als

 Software for managing Stream Deck devices with folders and actions
Software for managing Stream Deck devices with folders and actions

Streamduck Software for managing Stream Deck devices with folders and actions Project that will perhaps be better than streamdeck-ui Currently still i

Adaptors from AsyncRead/AsyncWrite to Stream/Sink using futures.

async-codec-lite Adaptors from AsyncRead/AsyncWrite to Stream/Sink using futures. async-codec-lite Adaptors from AsyncRead/AsyncWrite to Stream/Sink u

Lightweight websocket implement for stream transmission.

Lightws Lightweight websocket implement for stream transmission. Features Avoid heap allocation. Avoid buffering frame payload. Use vectored-io if ava

Stream API for tokio-udp.

UDPflow Stream API for tokio-udp. TCP-like UDP stream use tokio::net::UdpSocket; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use udpflow::{UdpListen

hello-world geyser plugin to stream accounts and transactions from a solana node

src/lib.rs: entrypoint src/plugin.rs: main plugin code to run: cargo build && solana-test-validator -r --geyser-plugin-config config.json note: make s

Alternative StreamMap fork of tokio-stream

streammap-ext This is a fork of StreamMap from tokio-stream crate. The only difference between the implementations is that this version of StreamMap n

Rust Stream::buffer_unordered where each future can have a different weight.

buffer-unordered-weighted buffer_unordered_weighted is a variant of buffer_unordered, where each future can be assigned a different weight. This crate

A simple web server(and library) to display server stats over HTTP and Websockets/SSE or stream it to other systems.

x-server-stats A simple web server(and library) to display server stats over HTTP and Websockets/SSE or stream it to other systems. x-server(in x-serv

Owner
Dylan C. Kendal
Co-Founder at Linear Forest
Dylan C. Kendal
Test whether a given stream is a terminal

is-terminal Test whether a given stream is a terminal is-terminal is a simple utility that answers one question: Is this a terminal? A "terminal", als

Dan Gohman 19 Dec 31, 2022
Stream-based visual programming language for systems observability

Stream-based visual programming language for systems observability. Metalens allows to build observability programs in a reactive and visual way. On L

Nikita Baksalyar 53 Dec 23, 2022
100% stream-based O(n) syntax highlighter for ANSI terminal

Lex-highlighter 100% stream-based $\mathcal O(n)$ syntax highlighter for ANSI terminal Warning This is proof-of-concept implementation and WON't be co

Abiria 10 Nov 17, 2023
Image cropper (and colorizer) for pdf scans

Image cropper for personal use (might not work with your pdfs) Requires pdfimages on the path to work properly It's thought just for my workflow so is

cdecompilador 2 Nov 7, 2022
decode a byte stream of varint length-encoded messages into a stream of chunks

length-prefixed-stream decode a byte stream of varint length-encoded messages into a stream of chunks This crate is similar to and compatible with the

James Halliday 4 Feb 26, 2022
Lightweight stream-based WebSocket implementation for Rust.

Tungstenite Lightweight stream-based WebSocket implementation for Rust. use std::net::TcpListener; use std::thread::spawn; use tungstenite::server::ac

Snapview GmbH 1.3k Jan 2, 2023
Multi-stream HTTP downloader using range requests

chooch - An Amazing Project Downloads files faster than wget/curl (in theory) using multiple connections. Chooch recycles the slowest connection and r

null 13 Sep 14, 2022
Transforms UDP stream into (fake) TCP streams that can go through Layer 3 & Layer 4 (NAPT) firewalls/NATs.

Phantun A lightweight and fast UDP to TCP obfuscator. Table of Contents Phantun Latest release Overview Usage 1. Enable Kernel IP forwarding 2. Add re

Datong Sun 782 Dec 30, 2022
General-purpose asynchronous socket stream.

async-socket This crate implements a general-purpose asynchronous socket. The Socket implements AsyncRead, AsyncWrite, Stream and Clone traits and thu

Kristijan Sedlak 3 Oct 20, 2021
A tool to stream the chats of Twitch channels as a CSV.

twitch2csv A tool to stream the chats of Twitch channels as a CSV. Installation You can use cargo to install this tool: cargo install -f twitch2csv Us

Clément Renault 2 Nov 20, 2021