Sha256: aebc87cbc68ec1fc8aeb7c28576b5c545ebf46abd095e0192834c15170ce338f
Contents?: true
Size: 1.22 KB
Versions: 62
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true require 'logger' # include this to add ability to log at different levels module Logging # @return [::Logger] def logger # @sg-ignore @logger ||= if defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger # @sg-ignore Rails.logger else ::Logger.new($stdout, level: log_level) end end # @param message [String,nil] # # @return [void] def error(message = nil, &block) logger.error(message, &block) end # @param message [String,nil] # # @return [void] def warn(message = nil, &block) logger.warn(message, &block) end # @param message [String,nil] # # @return [void] def info(message = nil, &block) logger.info(message, &block) end # @param message [String,nil] # # @return [void] def debug(message = nil, &block) logger.debug(message, &block) end # @param message [String,nil] # # @return [void] def finer(message = nil, &block) # No such level by default # # logger.finer(message, &block) end private # @sg-ignore # @return [Symbol] def log_level # @sg-ignore ENV.fetch('LOG_LEVEL', 'INFO').downcase.to_sym end end
Version data entries
62 entries across 62 versions & 1 rubygems