Module: BloatCheck
- Defined in:
- lib/bloat_check.rb,
lib/bloat_check/stats.rb,
lib/bloat_check/version.rb,
lib/bloat_check/wrap_requests.rb
Defined Under Namespace
Modules: WrapRequests
Classes: Stats
Constant Summary
collapse
- VERSION =
"0.0.5"
Class Method Summary
collapse
Class Method Details
.disable=(val) ⇒ Object
13
14
15
|
# File 'lib/bloat_check.rb', line 13
def self.disable=(val)
@disabled = val
end
|
.disabled? ⇒ Boolean
9
10
11
|
# File 'lib/bloat_check.rb', line 9
def self.disabled?
return true if @disabled
end
|
.log(message) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/bloat_check.rb', line 31
def self.log(message)
return block_given? && yield if disabled?
start = Stats.get
if block_given?
begin
ret = yield
ensure
(Stats.get - start).log(message)
end
ret
else
start.log(message)
end
end
|
.logger ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/bloat_check.rb', line 21
def self.logger
return @logger if @logger
return Rails.logger if defined? Rails
@logger ||= Logger.new(STDERR).tap { |logger|
logger.formatter = proc do |severity, datetime, progname, msg|
"#{msg}\n"
end
}
end
|
.logger=(logger) ⇒ Object
17
18
19
|
# File 'lib/bloat_check.rb', line 17
def self.logger=(logger)
@logger = logger
end
|