![]() ![]() This is because when you need to see verbose output from your plugin, verbose output from the rest of Jekyll will spew all over your terminal. If you want to control the output by adjusting log levels, you will quickly realize that attempting to adjust the log_level for Jekyll’s logger singleton is problematic. This is a global setting that affects all of Jekyll because only one Logger is used throughout Jekyll. You can send a message to Jekyll.logger from a plugin like this: "Hello, world" ![]() Log.warn "Red text at night, sailor's delight".red For example: puts "Green text and ham!".green It is easy to do this, just append a suffix to a string that indicates the color you want that string to be displayed with. Jekyll relies on the colorizer gem, so you can use colors on any terminal output written by puts, or sent to a log that writes to STDERR or STDOUT. It can be difficult to find what you are looking for as you watch miles and miles of log output spew onto your console, hour after hour, while you work on a problem. This plugin was originally called logger_factory, but it was renamed for version 2 because it was completely rewritten and became incompatible with previous versions. This article describes jekyll_plugin_logger, a Ruby gem that I created that allows you to quickly make custom loggers for your plugins. Use a new logger for each plugin that you write. Be sure to set the log level to warn or error when you are not debugging, and place the expression to be evaluated within a block (more on this later), so site generation goes full speed. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |