Sha256: 95d49eefacbbbde277440dfc0eedeaeb4676309a7db54ba0e067da0618042a43

Contents?: true

Size: 1.23 KB

Versions: 70

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

# Define a block where default logging is suppressed.
#
# Messages for actions within this block will be logged at `info` level instead
# of `notice`, so they will not be seen normally but will still be present
# when `verbose` logging is requested.
#
# > **Note:** Not available in apply block
Puppet::Functions.create_function(:without_default_logging) do
  # @param block The block where action logging is suppressed.
  # @return [Undef]
  # @example Suppress default logging for a series of functions
  #   without_default_logging() || {
  #     notice("Deploying on ${nodes}")
  #     get_targets($targets).each |$target| {
  #       run_task(deploy, $target)
  #     }
  #   }
  dispatch :without_default_logging do
    block_param 'Callable[0, 0]', :block
  end

  def without_default_logging
    unless Puppet[:tasks]
      raise Puppet::ParseErrorWithIssue
        .from_issue_and_stack(Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
                              action: 'without_default_logging')
    end

    executor = Puppet.lookup(:bolt_executor)
    # Send Analytics Report
    executor.report_function_call(self.class.name)

    executor.without_default_logging do
      yield
    end
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
bolt-3.0.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.44.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.42.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.40.2 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.40.1 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.38.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.37.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.36.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.35.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.34.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.33.2 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.33.1 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.32.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.31.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.30.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.29.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.28.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.27.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.26.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb
bolt-2.25.0 bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb