File: console.rb

package info (click to toggle)
ruby-async 2.36.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 400 kB
  • sloc: ruby: 1,938; makefile: 4
file content (42 lines) | stat: -rw-r--r-- 1,099 bytes parent folder | download
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
40
41
42
# frozen_string_literal: true

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

module Async
	# Shims for the console gem, redirecting warnings and above to `Kernel#warn`.
	#
	# If you require this file, the `async` library will not depend on the `console` gem.
	#
	# That includes any gems that sit within the `Async` namespace.
	#
	# This is an experimental feature.
	module Console
		# Log a message at the debug level. The shim is silent.
		def self.debug(...)
		end
		
		# Log a message at the info level. The shim is silent.
		def self.info(...)
		end
		
		# Log a message at the warn level. The shim redirects to `Kernel#warn`.
		def self.warn(*arguments, exception: nil, **options)
			if exception
				super(*arguments, exception.full_message, **options)
			else
				super(*arguments, **options)
			end
		end
		
		# Log a message at the error level. The shim redirects to `Kernel#warn`.
		def self.error(...)
			self.warn(...)
		end
		
		# Log a message at the fatal level. The shim redirects to `Kernel#warn`.
		def self.fatal(...)
			self.warn(...)
		end
	end
end