Skip to content

Commit

Permalink
Move public interface to Console::Interface and extend it into `Con…
Browse files Browse the repository at this point in the history
…sole`.
  • Loading branch information
ioquatix committed Nov 5, 2024
1 parent 4662b75 commit 719a069
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 34 deletions.
36 changes: 2 additions & 34 deletions lib/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,8 @@
# Copyright, 2021, by Cédric Boutillier.

require_relative "console/version"
require_relative "console/logger"
require_relative "console/interface"

module Console
class << self
def logger
Logger.instance
end

def logger= instance
Logger.instance= instance
end

def debug(...)
Logger.instance.debug(...)
end

def info(...)
Logger.instance.info(...)
end

def warn(...)
Logger.instance.warn(...)
end

def error(...)
Logger.instance.error(...)
end

def fatal(...)
Logger.instance.fatal(...)
end

def call(...)
Logger.instance.call(...)
end
end
Console.extend(Interface)
end
53 changes: 53 additions & 0 deletions lib/console/interface.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# frozen_string_literal: true

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

require_relative "logger"

module Console
# The public logger interface.
module Interface
# Get the current logger instance.
def logger
Logger.instance
end

# Set the current logger instance.
#
# The current logger instance is assigned per-fiber.
def logger= instance
Logger.instance= instance
end

# Emit a debug log message.
def debug(...)
Logger.instance.debug(...)
end

# Emit an informational log message.
def info(...)
Logger.instance.info(...)
end

# Emit a warning log message.
def warn(...)
Logger.instance.warn(...)
end

# Emit an error log message.
def error(...)
Logger.instance.error(...)
end

# Emit a fatal log message.
def fatal(...)
Logger.instance.fatal(...)
end

# Emit a log message with arbitrary arguments and options.
def call(...)
Logger.instance.call(...)
end
end
end

0 comments on commit 719a069

Please sign in to comment.