Class: Commons::Logging::Impl::LogFactoryImpl

Inherits:
LogFactory
  • Object
show all
Defined in:
lib/commons/logging/impl/log_factory_impl.rb

Constant Summary collapse

LOG_PROPERTY =

The property name used to identify the LOG_MODULE inclusion class name.

'commons.logging.Log'
LOG_MODULE =

The fully qualified class name of the log module.

'Commons::Logging::Log'
LOG_METHOD_NAME =

The log factory setter name.

'set_log_factory'
LOG4R_LOGGER_CLASS =
'Commons::Logging::Impl::Log4rLogger'
SIMPLELOG_LOGGER_CLASS =
'Commons::Logging::Impl::SimpleLog'

Constants inherited from LogFactory

LogFactory::FACTORY_DEFAULT, LogFactory::FACTORY_PROPERTIES, LogFactory::FACTORY_PROPERTY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from LogFactory

cache_factory, get_cached_factory, get_factory, get_log, new_factory

Constructor Details

#initializeLogFactoryImpl

Returns a new instance of LogFactoryImpl.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/commons/logging/impl/log_factory_impl.rb', line 64

def initialize
  super()
  
  @attributes = Hash.new
  
  # Already instantiated logger objects. keyed by name.
  @instances = Hash.new
  
  # The fully qualified class name of LOG_MODULE inclusion.
  @log_class_name = nil
  
  # The inclusion class object of the LOG_MODULE
  @log_class = nil
  
  # The one-argument LOG_METHOD_NAME method of the selected
  # LOG_MODULE inclusion class, if it exists.
  @log_method = nil          
end

Instance Attribute Details

#attributes=(value) ⇒ Object

Sets the attribute attributes

Parameters:

  • value

    the value to set the attribute attributes to.



59
60
61
# File 'lib/commons/logging/impl/log_factory_impl.rb', line 59

def attributes=(value)
  @attributes = value
end

#instances=(value) ⇒ Object

Sets the attribute instances

Parameters:

  • value

    the value to set the attribute instances to.



59
60
61
# File 'lib/commons/logging/impl/log_factory_impl.rb', line 59

def instances=(value)
  @instances = value
end

#log_class=(value) ⇒ Object

Sets the attribute log_class

Parameters:

  • value

    the value to set the attribute log_class to.



59
60
61
# File 'lib/commons/logging/impl/log_factory_impl.rb', line 59

def log_class=(value)
  @log_class = value
end

#log_method=(value) ⇒ Object

Sets the attribute log_method

Parameters:

  • value

    the value to set the attribute log_method to.



59
60
61
# File 'lib/commons/logging/impl/log_factory_impl.rb', line 59

def log_method=(value)
  @log_method = value
end

Instance Method Details

#get_attribute(name) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/commons/logging/impl/log_factory_impl.rb', line 84

def get_attribute(name)
  if @attributes.has_key?(name)
    return @attributes[name]
  else
    return nil
  end
end

#get_attribute_namesObject



93
94
95
# File 'lib/commons/logging/impl/log_factory_impl.rb', line 93

def get_attribute_names
  return @attributes.keys
end

#get_instance(name) ⇒ Object



98
99
100
101
102
103
104
# File 'lib/commons/logging/impl/log_factory_impl.rb', line 98

def get_instance(name)
  unless @instances.has_key?(name)
    @instances[name] = new_instance(name)
  end
  
  return @instances[name]
end

#releaseObject



107
108
109
# File 'lib/commons/logging/impl/log_factory_impl.rb', line 107

def release
  @instances.clear
end

#remove_attribute(name) ⇒ Object



112
113
114
# File 'lib/commons/logging/impl/log_factory_impl.rb', line 112

def remove_attribute(name)
  @attributes.delete(name)
end

#set_attribute(name, value) ⇒ Object



117
118
119
120
121
122
123
# File 'lib/commons/logging/impl/log_factory_impl.rb', line 117

def set_attribute(name, value)
  if value == nil
    @attributes.delete(name)
  else
    @attributes[name] = value
  end
end