npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

log-color-highlight

v1.6.0

Published

Node Js command line utility for highlighting log files

Downloads

22

Readme

log-color-highlight

Node Js command line utility for highlighting log files.

Demo

Install

$ npm install log-color-highlight -g

Usage

lch [options] -style1 regex1 [-style2 regex2] ...

Options

-f filePath     Input file path.
                If this is not provided standard input is used
-c configPath   Path to configuration file.
-s style        Implicit style.
-cs             Case sensitive.
                By default text matching is done case insensitive.
-p              Add style/modifier preset.
-h --help       Prints this help message.

Highlighting

Multiple styles may be combined using dot notation.

echo Information, warnings, errors | lch -green info -yellow.bold warn error failure

If no style is specified it defaults to red. This behavior may be altered with -s option which is mostly useful if specified in configuration files.

echo Some errors | lch error

Styles

Colors: black, red, green, yellow, blue, magenta, cyan, white, gray

Background colors: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite

Styling: reset, bold, dim, italic, underline, inverse, hidden, strikethrough

Modifiers

cs Forces matches to be case sensitive..

echo Info, Warn | lch -green.cs info -yellow warn

wl Highlights the whole line

echo highlight whole line | lch -green.wl whole -yellow light

esc Escapes regex special characters

echo [error] ... [info] | lch -red.esc [error] -yellow "\[info\]"

Presets

Define common style. Useful together with configuration files.

echo "[error] ... [info]" | lch -p err=red.bold -p inf=yellow.bold -err error -inf info

Configuration file

Supports the same highlighting syntax as used from command line. In addition allows multiple lines and comments.

# Presets
-p failure=red.bold
-p success=green.bold

# Highlighting
-yellow.bold warn warning warnings deprecated

-success success successful successfully
-success "Operation.*completed"

-failure "Operation.*failed"
-failure err error errors erroneous
-failure wrong
-failure fail failure
echo Successful, warnings, errors | lch -c lch.conf

Examples

Highlight 'error' and 'warn' in default color (red)

echo some errors and warnings | lch error warn

Styles

echo "log color highlight" | lch -red.bold log -blue.italic.underline highlight

Implicit style

echo "implicit style" | lch -s bold -red implicit -red.reset style

Force case sensitive globally

echo "case sensitive" | lch -cs sensitive CASE

Toggle case sensitivity per pattern using cs and ci modifiers

echo "case sensitive Case Sensitive" | lch -green.cs sensitive -red case
echo "case sensitive Case Sensitive" | lch -cs -green sensitive -red.ci.bold case

Regular expressions

echo "using regular expressions" | lch -green .*regular -blue exp.*

Escape regex special characters. Following examples are equivalent.

echo "[ERROR] On receive (ctrl) - monitorId" | lch -red.esc [error] -cyan.esc "receive (ctrl) - monitorId"
echo "[ERROR] On receive (ctrl) - monitorId" | lch -red \[error\] -cyan "receive \(ctrl\) - monitorId"

Later options take precedence over previous ones

echo "log color highlight" | lch -green "log color highlight" -blue "color" -red "lor hi"

Nested highlights

echo "log color highlight" | lch -blue "color" -red "log color"

Test

cd log-color-highlight
npm install
npm test

Changelog

1.4.0 whole line modifier
      updated cli help message/readme
1.3.0 config file is searched in user home folder or LCH_CONFIG env variable path
1.2.0 presets
1.1.1 regular expression escape modifier
1.1.0 case sensitivity modifiers

Alternatives

Lch doesn't fit? Try one of the following.