README.md in zlogger-0.0.2 vs README.md in zlogger-0.1.0

- old
+ new

@@ -37,10 +37,26 @@ logger = Zlogger::Client.new logger.debug "log this debug message" The `logger` client object behaves like a standard ruby Logger. +## Using zlogger client in a Rails application with Phusion Passenger +Phusion passenger uses a forking model. ZeroMQ contexts do not survive a process fork, so it is important to start +the zlogger client after passenger does the process fork. Using the following code snippet in +config/environments/production.rb will allow zlogger to be used as the rails logger correctly: + + # production log to Zlogger + if defined?(PhusionPassenger) + # inside passenger, only create the zlogger after the app starts (and has been forked) + PhusionPassenger.on_event(:starting_worker_process) do |forked| + Rails.logger = Zlogger::Client.new({address: ENV['ZLOGGER_ADDRESS'], port: ENV['ZLOGGER_PORT']}) + end + else + # rake tasks, irb, etc. Anything not in passenger: use a zlogger immediately. + Rails.logger = Zlogger::Client.new({address: ENV['ZLOGGER_ADDRESS'], port: ENV['ZLOGGER_PORT']}) + end + ## Contributing 1. Fork it ( https://github.com/[my-github-username]/zlogger/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`)