Sha256: 1845e42e6ec7d55dfb762863ece60bd93a083465853089f04ac514e51b3407cf

Contents?: true

Size: 642 Bytes

Versions: 6

Compression:

Stored size: 642 Bytes

Contents

# frozen_string_literal: true

require 'logger'

module Netsoul
  module Logging # :nodoc:
    PREFIX = '[Netsoul-Ruby]'.freeze

    class << self
      attr_writer :logger
    end

    def self.logger
      @logger ||= ::Logger.new(STDERR).tap do |logger|
        logger.level = Logger::INFO
        logger.formatter = proc do |severity, datetime, _progname, msg|
          "#{severity} [#{datetime.strftime('%Y-%m-%d %H:%M:%S.%L'.freeze)}] #{msg}\n"
        end
      end
    end

    private

    def log(level, message)
      Netsoul::Logging.logger.send(level.to_sym, "#{PREFIX} #{message}") if Netsoul::Logging.logger
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
netsoul-2.3.7 lib/netsoul/logging.rb
netsoul-2.3.6 lib/netsoul/logging.rb
netsoul-2.3.5 lib/netsoul/logging.rb
netsoul-2.3.4 lib/netsoul/logging.rb
netsoul-2.3.3 lib/netsoul/logging.rb
netsoul-2.3.2 lib/netsoul/logging.rb