Class: Lutaml::Model::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/model/services/logger.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.warn(message, path = nil) ⇒ Object



4
5
6
# File 'lib/lutaml/model/services/logger.rb', line 4

def self.warn(message, path = nil)
  new.call(message, :warn, path)
end

.warn_auto_handling(name:, caller_file:, caller_line:) ⇒ Object

Outputs a warning message that

`<name>` is handled by default. No need to explicitly
define at `<caller_file>:<caller_line>`.

Parameters:

  • name (String)
  • caller_file (String)
  • caller_line (Integer)


28
29
30
# File 'lib/lutaml/model/services/logger.rb', line 28

def self.warn_auto_handling(name:, caller_file:, caller_line:)
  warn("`#{name}` is handled by default. No need to explicitly define at `#{caller_file}:#{caller_line}`")
end

.warn_future_deprecation(old:, replacement:) ⇒ Object

Outputs a warning message that

Usage of `old` name is deprecated will be removed in the next major
release. Please use the `replacement`` instead.

Parameters:

  • old: (String)

    The name of the deprecated class or method

  • replacement: (String)

    The name of the replacement class or method



14
15
16
17
18
19
# File 'lib/lutaml/model/services/logger.rb', line 14

def self.warn_future_deprecation(old:, replacement:)
  trace = caller_locations(8..8).first # first locations after the gem's internal files
  warn(
    "Usage of `#{old}` is deprecated and will be removed in the next major release. Please use `#{replacement}` instead.", "#{trace.path}:#{trace.lineno}:"
  )
end

Instance Method Details

#call(message, type, path = nil) ⇒ Object



32
33
34
# File 'lib/lutaml/model/services/logger.rb', line 32

def call(message, type, path = nil)
  Warning.warn format_message(message, type, path)
end