From cad197553b150e6cfd9d4110baba750c0dd88ca2 Mon Sep 17 00:00:00 2001 From: Andy Meneely Date: Tue, 18 Nov 2014 03:14:24 -0500 Subject: [PATCH] Better logging and docs thereof --- CHANGELOG.md | 1 + README.md | 10 ++++++++++ lib/squib/deck.rb | 8 ++++++++ 3 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ce8bc4..177e256 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ # Custom layouts now support loading & merging multiple files, see README and updated sample # Samples now show that you can use text instead of symbols +# Improved logging, and documentation on increasing logger verboseness # Better regression testing technique that tracks when a sample has changed. ## v0.0.5 diff --git a/README.md b/README.md index de8684b..8a255fd 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,16 @@ See the `custom_config` sample found [here](https://github.com/andymeneely/squib {include:file:samples/custom_config.rb} +## Making Squib Verbose + +By default, Squib's logger is set to WARN, but more fine-grained logging is embedded in the code. To set the logger, just put this at the top of your script: + +```ruby +Squib::logger.level = Logger::INFO +``` + +If you REALLY want to see tons of output, you can also set DEBUG, but that's not intended for general consumption. + ## Staying DRY Squib tries to keep you DRY (Don't Repeat Yourself) with the following features: diff --git a/lib/squib/deck.rb b/lib/squib/deck.rb index f85468d..d5bb1e0 100644 --- a/lib/squib/deck.rb +++ b/lib/squib/deck.rb @@ -63,6 +63,7 @@ module Squib @progress_bar = Squib::Progress.new(false) @text_hint = :off cards.times{ @cards << Squib::Card.new(self, width, height) } + show_info(config, layout) load_config(config) load_layout(layout) if block_given? @@ -95,6 +96,7 @@ module Squib # @api private def load_config(file) if File.exists?(file) && config = YAML.load_file(file) + Squib::logger.info { " using config: #{file}" } config = Squib::CONFIG_DEFAULTS.merge(config) @dpi = config['dpi'].to_i @text_hint = config['text_hint'] @@ -108,6 +110,7 @@ module Squib # @api private def load_layout(files) @layout = {} + Squib::logger.info { " using layout(s): #{files}" } Array(files).each do |file| yml = @layout.merge(YAML.load_file(file)) yml.each do |key, value| @@ -159,6 +162,11 @@ module Squib end end + def show_info(config, layout) + Squib::logger.info "Squib v#{Squib::VERSION}" + Squib::logger.info " building #{@cards.size} #{@width}x#{@height} cards" + end + ################## ### PUBLIC API ### ##################