Socket
Book a DemoInstallSign in
Socket

log-pretty

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

log-pretty

0.2.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

LogPretty

LogPretty adds functionaltiy to print to STDOUT or any logging device using ANSI escape colors and formatting.

You can echo the following to any ANSI-compatible terminal to see blue output.

$ echo "\e[34mHello world!\e[0m"

The '34' is the code for blue and the '0' at the end resets all styles. You can find a helpful list of ANSI codes here.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add log-pretty

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install log-pretty

Then, if you would like to use the #logp method as a top-level method, inlude the LogPretty module.

In Rails, this can be done by adding fild `config/initializers/log-pretty.rb' with the following content.

include LogPretty

Usage

The main method #logp (which stands for 'log pretty') logs pretty content (colors, formatting, etc.) to standard output. This can be useful for writing scrips and CLIs where you would like the user to see prettier content in their terminal.

Supply a String argument for the content and any optional formatting arguments.

For instance, if I wanted to log "Red alert!" to the terminal in red, underlined text, I would invoke #logp like this.

logp('Red alert!', color: :red, format: :underline)

Or, if I wanted multiple formats, I can supply an array.

logp('Red alert!', color: :red, format: %i[underline bold italic])

Avaliable optional keys are:

  • color
  • background
  • format

Additionally, you can specify a log file with an optional compatible Logger formatter proc.

l = LogPretty::Logger.new('log/log_pretty.log', formatter)
l.logp("Hello, world! 👋")

By default, LogPretty will write to the logging file in addition to STDOUT and return the output to the caller.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the LogPretty project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

FAQs

Package last updated on 12 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.