Module: Roda::EnhancedLogger::Current

Extended by:
Current
Included in:
Current
Defined in:
lib/roda/enhanced_logger/current.rb

Overview

Data collection for request in current thread

Instance Method Summary collapse

Instance Method Details

#accrued_database_timeNumeric

The accrued database time

Returns:

  • (Numeric)


24
25
26
# File 'lib/roda/enhanced_logger/current.rb', line 24

def accrued_database_time
  Thread.current[:accrued_database_time]
end

#accrued_database_time=(value) ⇒ Numeric

Set accrued database time

Parameters:

  • value (Numeric)

    the value to set

Returns:

  • (Numeric)

    the new value



33
34
35
# File 'lib/roda/enhanced_logger/current.rb', line 33

def accrued_database_time=(value)
  Thread.current[:accrued_database_time] = value
end

#database_query_countObject



42
43
44
# File 'lib/roda/enhanced_logger/current.rb', line 42

def database_query_count
  Thread.current[:database_query_count]
end

#database_query_count=(value) ⇒ Object



46
47
48
# File 'lib/roda/enhanced_logger/current.rb', line 46

def database_query_count=(value)
  Thread.current[:database_query_count] = value
end

#increment_accrued_database_time(value) ⇒ Numeric

Increment the accrued database time

Parameters:

  • value (Numeric)

    the value to increment

Returns:

  • (Numeric)

    the updated value



17
18
19
20
# File 'lib/roda/enhanced_logger/current.rb', line 17

def increment_accrued_database_time(value)
  Thread.current[:accrued_database_time] ||= 0
  Thread.current[:accrued_database_time] += value
end

#increment_database_query_count(value = 1) ⇒ Object



37
38
39
40
# File 'lib/roda/enhanced_logger/current.rb', line 37

def increment_database_query_count(value = 1)
  Thread.current[:database_query_count] ||= 0
  Thread.current[:database_query_count] += value
end

#resetObject

Reset the counters



51
52
53
54
55
# File 'lib/roda/enhanced_logger/current.rb', line 51

def reset
  self.accrued_database_time = nil
  self.database_query_count = nil
  true
end