Class: Vitals::Reporters::ConsoleReporter

Inherits:
BaseReporter show all
Defined in:
lib/vitals/reporters/console_reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseReporter

#time

Constructor Details

#initialize(category: 'main', output: $stdout, format: nil) ⇒ ConsoleReporter

Returns a new instance of ConsoleReporter.



5
6
7
8
9
# File 'lib/vitals/reporters/console_reporter.rb', line 5

def initialize(category:'main', output: $stdout, format:nil)
  @format = format
  @category = category
  @output = output
end

Instance Attribute Details

#formatObject

Returns the value of attribute format.



3
4
5
# File 'lib/vitals/reporters/console_reporter.rb', line 3

def format
  @format
end

Instance Method Details

#count(m, v) ⇒ Object



19
20
21
# File 'lib/vitals/reporters/console_reporter.rb', line 19

def count(m, v)
  print "#{@category} COUNT #{self.format.format(m)} #{v}"
end

#gauge(m, v) ⇒ Object



15
16
17
# File 'lib/vitals/reporters/console_reporter.rb', line 15

def gauge(m, v)
  print "#{@category} GAUGE #{self.format.format(m)} #{v}"
end

#inc(m) ⇒ Object



11
12
13
# File 'lib/vitals/reporters/console_reporter.rb', line 11

def inc(m)
  print "#{@category} INC #{self.format.format(m)}"
end


27
28
29
# File 'lib/vitals/reporters/console_reporter.rb', line 27

def print(str)
  @output.printf("#{ str }\n")
end

#timing(m, v) ⇒ Object



23
24
25
# File 'lib/vitals/reporters/console_reporter.rb', line 23

def timing(m, v)
  print "#{@category} TIME #{self.format.format(m)} #{v}"
end