Sha256: c530f4030b1a9ec153fd03edceb3e257080c2bd0cc53edf451690668b82ff66b

Contents?: true

Size: 903 Bytes

Versions: 28

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

class Puppet::Util::Profiler::Logging
  def initialize(logger, identifier)
    @logger = logger
    @identifier = identifier
    @sequence = Sequence.new
  end

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

  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

  def shutdown
    # nothing to do
  end

  class Sequence
    INITIAL = 0
    SEPARATOR = '.'

    def initialize
      @elements = [INITIAL]
    end

    def next
      @elements[-1] += 1
    end

    def down
      @elements << INITIAL
    end

    def up
      @elements.pop
    end

    def to_s
      @elements.join(SEPARATOR)
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
puppet-8.10.0 lib/puppet/util/profiler/logging.rb
puppet-8.10.0-x86-mingw32 lib/puppet/util/profiler/logging.rb
puppet-8.10.0-x64-mingw32 lib/puppet/util/profiler/logging.rb
puppet-8.10.0-universal-darwin lib/puppet/util/profiler/logging.rb
puppet-8.9.0 lib/puppet/util/profiler/logging.rb
puppet-8.9.0-x86-mingw32 lib/puppet/util/profiler/logging.rb
puppet-8.9.0-x64-mingw32 lib/puppet/util/profiler/logging.rb
puppet-8.9.0-universal-darwin lib/puppet/util/profiler/logging.rb
puppet-8.8.1 lib/puppet/util/profiler/logging.rb
puppet-8.8.1-x86-mingw32 lib/puppet/util/profiler/logging.rb
puppet-8.8.1-x64-mingw32 lib/puppet/util/profiler/logging.rb
puppet-8.8.1-universal-darwin lib/puppet/util/profiler/logging.rb
puppet-8.7.0 lib/puppet/util/profiler/logging.rb
puppet-8.7.0-x86-mingw32 lib/puppet/util/profiler/logging.rb
puppet-8.7.0-x64-mingw32 lib/puppet/util/profiler/logging.rb
puppet-8.7.0-universal-darwin lib/puppet/util/profiler/logging.rb
puppet-8.6.0 lib/puppet/util/profiler/logging.rb
puppet-8.6.0-x86-mingw32 lib/puppet/util/profiler/logging.rb
puppet-8.6.0-x64-mingw32 lib/puppet/util/profiler/logging.rb
puppet-8.6.0-universal-darwin lib/puppet/util/profiler/logging.rb