Sha256: ed653e7065e928b8b8d3238e9bfe1ff660476110f1798f324a0a9a494629fee7

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020-2024, by Samuel Williams.

require_relative 'client'

require 'console/logger'

module Async
	module Container
		module Notify
			# Implements a general process readiness protocol with output to the local console.
			class Console < Client
				# Open a notification client attached to the current console.
				def self.open!(logger = ::Console)
					self.new(logger)
				end
				
				# Initialize the notification client.
				# @parameter logger [Console::Logger] The console logger instance to send messages to.
				def initialize(logger)
					@logger = logger
				end
				
				# Send a message to the console.
				def send(level: :debug, **message)
					@logger.send(level, self) {message}
				end
				
				# Send an error message to the console.
				# @parameters text [String] The details of the error condition.
				# @parameters message [Hash] Additional details to send with the message.
				def error!(text, **message)
					send(status: text, level: :error, **message)
				end
			end
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
async-container-0.18.3 lib/async/container/notify/console.rb
async-container-0.18.2 lib/async/container/notify/console.rb
async-container-0.18.1 lib/async/container/notify/console.rb