Awesome
jekyll_plugin_logger
jekyll_plugin_logger
is a Jekyll plugin, packaged as a Ruby gem, that provides colored console logs for Jekyll plugins.
It is based on the standard Ruby Logger
class.
Log levels are normally set from _config.yml
:
- 0:
debug
- 1:
info
- 2:
warn
- 3:
error
- 4:
fatal
- 5:
unknown
(displays asANY
)
Usage
The demo/_plugins/
directory demonstrates two ways of working with jekyll_plugin_logger
:
liquid_tag.rb
, a Jekyll plugin subclassed fromLiquid::Tag
.support_tag.rb
, a Jekyll plugin subclassed fromJekyllSupport::JekyllTag
.
Installation
To A Jekyll Website
Add the following to your Jekyll website's Gemfile
:
group :jekyll_plugins do
gem 'jekyll_plugin_logger'
end
Install all of the dependent gems of your Jekyll website by typing:
$ bundle
To A Jekyll Plugin Packaged As A Gem
Add the following to your Gem’s .gemspec
:
Gem::Specification.new do |spec|
spec.add_dependency 'jekyll_plugin_logger'
end
Install all of the dependent gems of your Gem by typing:
$ bundle
Configuration
The default log level is info
.
You can change the log level by editing _config.yml
and adding a plugin_loggers
section.
Within that section, add an entry for the fully qualified name of your plugin class.
For example, the fully qualified class names of the Jekyll plugins provided in demo/_plugins/
are Raw::InlineTag
and Support::InlineTag
, respectively.
Their log levels can be set to debug
with the following entries in _config.yml
:
plugin_loggers:
Raw::InlineTag: debug # Notice the module name is specified as well as the class name
Support::InlineTag: debug # Notice the module name is specified as well as the class name
Run the Demo
Run the demo by typing:
$ demo/_bin/debug -r
See what happens to the output when you edit the logging levels in the plugin_loggers
section of _config.yml
.
You will have to restart the demo after each modification to _config.yml
in order to see the output change.
Additional Information
More information is available on Mike Slinn's web site about Jekyll plugins.
Development
After checking out the jekyll_plugin_logger
repository,
run bin/setup
to install dependencies,
which includes development dependencies.
You can then run bin/console
for an interactive prompt that will allow you to experiment.
Build and Install Locally
To build and install this gem onto your local machine, run:
$ bundle exec rake install
jekyll_plugin_logger 1.0.0 built to pkg/jekyll_plugin_logger-0.1.0.gem.
jekyll_plugin_logger (1.0.0) installed.
Examine the newly built gem:
$ gem info jekyll_plugin_logger
*** LOCAL GEMS ***
jekyll_plugin_logger (1.0.0)
Author: Mike Slinn
Homepage:
https://github.com/mslinn/jekyll_plugin_logger
License: MIT
Installed at: /home/mslinn/.gems
Generates a Jekyll logger with colored output.
Build and Push to RubyGems
To release a new version,
-
Update the version number in
version.rb
. -
Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
-
Run the following:
$ bundle exec rake release
The above creates a git tag for the version, commits the created tag, and pushes the new
.gem
file to RubyGems.org.
Contributing
- Fork the project
- Create a descriptively named feature branch
- Add your feature
- Submit a pull request
License
The gem is available as open source under the terms of the MIT License.