
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
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.
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
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:
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.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the LogPretty project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that log-pretty demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.