Module: Samuel

Extended by:
Samuel
Included in:
Samuel
Defined in:
lib/samuel.rb,
lib/samuel/diary.rb,
lib/samuel/loader.rb,
lib/samuel/log_entries/base.rb,
lib/samuel/log_entries/net_http.rb,
lib/samuel/driver_patches/net_http.rb,
lib/samuel/log_entries/http_client.rb,
lib/samuel/driver_patches/http_client.rb

Defined Under Namespace

Modules: Diary, DriverPatches, Loader, LogEntries

Constant Summary collapse

VERSION =
"0.3.3"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject



31
32
33
# File 'lib/samuel.rb', line 31

def config
  Thread.current[:__samuel_config] ? Thread.current[:__samuel_config] : @config
end

#loggerObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/samuel.rb', line 20

def logger
  @logger = nil if !defined?(@logger)
  return @logger if !@logger.nil?

  if defined?(Rails) && Rails.respond_to?(:logger)
    @logger = Rails.logger
  else
    @logger = Logger.new(STDOUT)
  end
end

Instance Method Details

#reset_configObject



44
45
46
47
# File 'lib/samuel.rb', line 44

def reset_config
  Thread.current[:__samuel_config] = nil
  @config = {:label => nil, :labels => {}, :filtered_params => []}
end

#with_config(options = {}) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/samuel.rb', line 35

def with_config(options = {})
  original_config = config.dup
  nested = !Thread.current[:__samuel_config].nil?

  Thread.current[:__samuel_config] = original_config.merge(options)
  yield
  Thread.current[:__samuel_config] = nested ? original_config : nil
end