Skip to content

Commit

Permalink
Use NullLogger in case ActiveFedora::Base.logger is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
awead committed Nov 30, 2015
1 parent fd92cd9 commit 574897b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion curation_concerns-models/app/jobs/audit_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def run_audit
ChecksumAuditLog.create!(pass: passing, file_set_id: id, version: uri, file_id: file_id)
end

private

def logger
ActiveFedora::Base.logger
ActiveFedora::Base.logger || CurationConcerns::NullLogger.new
end
end
1 change: 1 addition & 0 deletions curation_concerns-models/lib/curation_concerns/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Models
autoload :Utils, 'curation_concerns/models/utils'
autoload :Permissions
autoload :Messages
autoload :NullLogger
eager_autoload do
autoload :Configuration
autoload :Name
Expand Down
10 changes: 10 additions & 0 deletions curation_concerns-models/lib/curation_concerns/null_logger.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module CurationConcerns
class NullLogger < Logger
def initialize(*args)
end

# allows all the usual logger method calls (warn, info, error, etc.)
def add(*args, &block)
end
end
end
10 changes: 10 additions & 0 deletions spec/lib/curation_concerns/null_logger_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'spec_helper'

describe CurationConcerns::NullLogger do
subject { described_class.new }
its(:debug) { is_expected.to be_nil }
its(:info) { is_expected.to be_nil }
its(:warn) { is_expected.to be_nil }
its(:error) { is_expected.to be_nil }
its(:fatal) { is_expected.to be_nil }
end

0 comments on commit 574897b

Please sign in to comment.