Better logging and docs thereof
parent
7e1f02906f
commit
cad197553b
|
|
@ -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
|
||||
|
|
|
|||
10
README.md
10
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:
|
||||
|
|
|
|||
|
|
@ -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 ###
|
||||
##################
|
||||
|
|
|
|||
Loading…
Reference in New Issue