Skip to content

Commit

Permalink
Make logging configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
bittersweet committed Nov 2, 2010
1 parent d01aad3 commit 90d3863
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ Finally, Jzip has some options that you can configure in the @environment.rb@ fi

* @:minify@ - Minify the merged Javascript file using the JSMin library (default: true when in production environment)
* @:always_update@ - Merge (and minify when specified) the Jzip templates on every page request when outdated (default: true when not in production environment)
* @:logger@ - What is used for logging, you can pass through :puts or :logger to login to stdout or Rails.logger.debug respectively (default: false)

You can specify a Jzip option by putting the following in your @environment.rb@ file:

<pre>
Jzip::Engine.options[:minify] = false
Jzip::Engine.options[:always_update] = true
Jzip::Engine.options[:logger] = :puts
</pre>

h3. In the Rails console
Expand Down
3 changes: 2 additions & 1 deletion lib/jzip/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module Engine

@options = {
:minify => Rails.env.production?,
:always_update => !Rails.env.production?
:always_update => !Rails.env.production?,
:logger => false
}

attr_reader :root_dir, :options
Expand Down
7 changes: 6 additions & 1 deletion lib/jzip/engine/support/notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ module Notifier

def notify(message)
string = wrap(message)
Rails.logger.info(string)
case Jzip::Engine.options[:logger]
when :puts
puts string
when :logger
Rails.logger.debug(string)
end
end

private
Expand Down

0 comments on commit 90d3863

Please sign in to comment.