-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathwithout_default_logging.rb
More file actions
39 lines (35 loc) · 1.23 KB
/
without_default_logging.rb
File metadata and controls
39 lines (35 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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