File: io_context.rb

package info (click to toggle)
ruby-puppet-resource-api 1.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,232 kB
  • sloc: ruby: 9,573; sh: 4; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 574 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

require 'puppet/resource_api/base_context'

# Implement Resource API Conext to log through an IO object, defaulting to `$stderr`.
# There is no access to a device here. You can supply a transport if necessary.
class Puppet::ResourceApi::IOContext < Puppet::ResourceApi::BaseContext
  attr_reader :transport

  def initialize(definition, target = $stderr, transport = nil)
    super(definition)
    @target = target
    @transport = transport
  end

  protected

  def send_log(level, message)
    @target.puts "#{level}: #{message}"
  end
end