Class: Lims::Core::Persistence::Logger::Store

Inherits:
Store show all
Defined in:
lib/lims-core/persistence/logger/store.rb

Overview

An Logger::Store, a store ‘logging’ object instead of saving them.

Constant Summary

Constants inherited from Store

Store::DIRTY_ATTRIBUTE_STRATEGY_DEEP_COPY, Store::DIRTY_ATTRIBUTE_STRATEGY_MD5, Store::DIRTY_ATTRIBUTE_STRATEGY_QUICK_HASH, Store::DIRTY_ATTRIBUTE_STRATEGY_SHA1

Instance Attribute Summary collapse

Attributes inherited from Store

#dirty_attribute_strategy

Instance Method Summary collapse

Methods inherited from Store

#base_module, base_module, const_missing, #create_session, #transaction, #with_session

Constructor Details

#initialize(logger, method = :info, *args) ⇒ Store

Create a store with an underlying logger. send information to the logger.

Parameters:

  • logger (Logger, file)
  • method (Symbol, String) (defaults to: :info)

    the method call to



22
23
24
25
26
27
28
29
# File 'lib/lims-core/persistence/logger/store.rb', line 22

def initialize(logger, method=:info, *args)
  @logger = case logger
            when ::Logger then  logger
            else ::Logger.new(logger)
            end
  @method = method
  super(*args)
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



15
16
17
# File 'lib/lims-core/persistence/logger/store.rb', line 15

def logger
  @logger
end

#methodObject (readonly)

Returns the value of attribute method.



16
17
18
# File 'lib/lims-core/persistence/logger/store.rb', line 16

def method
  @method
end

Instance Method Details

#log(msg) ⇒ Object



31
32
33
# File 'lib/lims-core/persistence/logger/store.rb', line 31

def log(msg)
  @logger.send(@method, msg)
end