class Librarian::Logger

Constants

LIBRARIAN_PATH

Attributes

environment[RW]

Public Class Methods

new(environment) click to toggle source
# File lib/librarian/logger.rb, line 11
def initialize(environment)
  self.environment = environment
end

Public Instance Methods

debug(string = nil, &block) click to toggle source
# File lib/librarian/logger.rb, line 27
def debug(string = nil, &block)
  return unless ui

  if ui.respond_to?(:debug_line_numbers) && ui.debug_line_numbers
    loc = caller.find{|l| !(l =~ /in `debug'$/)}
    if loc =~ /^(.+):(\d+):in `(.+)'$/
      loc = "#{Pathname.new($1).relative_path_from(LIBRARIAN_PATH)}:#{$2}:in `#{$3}'"
    end
    ui.debug { "[Librarian] #{string || yield} [#{loc}]" }
  else
    ui.debug { "[Librarian] #{string || yield}" }
  end
end
info(string = nil) { || ... } click to toggle source
# File lib/librarian/logger.rb, line 21
def info(string = nil, &block)
  return unless ui

  ui.info(string || yield)
end
relative_path_to(path) click to toggle source
# File lib/librarian/logger.rb, line 41
def relative_path_to(path)
  environment.project_relative_path_to(path)
end
warn(string = nil) { || ... } click to toggle source
# File lib/librarian/logger.rb, line 15
def warn(string = nil, &block)
  return unless ui

  ui.warn(string || yield)
end

Private Instance Methods

ui() click to toggle source
# File lib/librarian/logger.rb, line 47
def ui
  environment.ui
end