Sha256: 938241f21042e7873d4f4ba1162cf49d1c1509003bd4b859c6e60b48d3ccfefd

Contents?: true

Size: 893 Bytes

Versions: 48

Compression:

Stored size: 893 Bytes

Contents

# encoding: UTF-8
module ForestLiana
  class Logger
    class << self
      def log
        if ForestLiana.logger != nil
          logger = ForestLiana.logger
        else
          logger = ::Logger.new(STDOUT)
          logger_colors = {
            DEBUG: 34,
            WARN: 33,
            ERROR: 31,
            INFO: 37
          }

          logger.formatter = proc do |severity, datetime, progname, message|
            displayed_message = "[#{datetime.to_s(:db)}] Forest 🌳🌳🌳  " \
                  "#{message}\n"
                "\e[#{logger_colors[severity.to_sym]}m#{displayed_message}\033[0m"
          end
          logger
        end
      end
    end
  end

  class Reporter
    def self.report (error)
      ForestLiana.reporter.report error if ForestLiana.reporter
    end
  end
end

FOREST_LOGGER = ForestLiana::Logger.log
FOREST_REPORTER = ForestLiana::Reporter

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
forest_liana-7.5.1 config/initializers/logger.rb
forest_liana-7.5.0 config/initializers/logger.rb
forest_liana-7.4.5 config/initializers/logger.rb
forest_liana-7.4.4 config/initializers/logger.rb
forest_liana-7.4.3 config/initializers/logger.rb
forest_liana-7.4.2 config/initializers/logger.rb
forest_liana-7.4.1 config/initializers/logger.rb
forest_liana-7.4.0 config/initializers/logger.rb