Skip to content

Commit

Permalink
[merb-exceptions] Create log dir if not already present
Browse files Browse the repository at this point in the history
This avoids errors when running the specs from a
fresh clone where the log dir is not yet present.
Also, it would resolve errors where a developer
forgot to create or removed the Merb.root/log dir.
  • Loading branch information
snusnu committed Oct 31, 2009
1 parent 2445f17 commit b1081ee
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion merb-exceptions/lib/merb-exceptions/exceptions_helper.rb
Expand Up @@ -21,7 +21,14 @@ def notify_of_exceptions
rescue Exception => e
exceptions = request.exceptions << e
Merb.logger.fatal!("Exception Notification Failed:\n" + (exceptions).inspect)
File.open(Merb.root / 'log' / 'notification_errors.log', 'a') do |log|

log_dir = Merb.root / 'log'
unless File.directory?(log_dir)
require 'fileutils'
FileUtils.mkdir_p(log_dir)
end

File.open(log_dir / 'notification_errors.log', 'a') do |log|
log.puts("Exception Notification Failed:")
exceptions.each do |e|
log.puts(Merb.exception(e))
Expand Down

0 comments on commit b1081ee

Please sign in to comment.