Class: Puppet::Util::Profiler::Logging

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/profiler/logging.rb

Direct Known Subclasses

ObjectCounts, WallClock

Defined Under Namespace

Classes: Sequence

Instance Method Summary collapse

Constructor Details

#initialize(logger, identifier) ⇒ Logging

Returns a new instance of Logging.



4
5
6
7
8
# File 'lib/puppet/util/profiler/logging.rb', line 4

def initialize(logger, identifier)
  @logger = logger
  @identifier = identifier
  @sequence = Sequence.new
end

Instance Method Details

#finish(context, description, metric_id) ⇒ Object



16
17
18
19
20
# File 'lib/puppet/util/profiler/logging.rb', line 16

def finish(context, description, metric_id)
  profile_explanation = do_finish(context, description, metric_id)[:msg]
  @sequence.up
  @logger.call("PROFILE [#{@identifier}] #{@sequence} #{description}: #{profile_explanation}")
end

#shutdownObject



22
23
24
# File 'lib/puppet/util/profiler/logging.rb', line 22

def shutdown
  # nothing to do
end

#start(description, metric_id) ⇒ Object



10
11
12
13
14
# File 'lib/puppet/util/profiler/logging.rb', line 10

def start(description, metric_id)
  @sequence.next
  @sequence.down
  do_start(description, metric_id)
end