Sha256: 231633b376cf3d78c0dc2481b842bc2a86f82f03e1b0f07c8a2fd464bbfd4d41

Contents?: true

Size: 1.12 KB

Versions: 26

Compression:

Stored size: 1.12 KB

Contents

module Souls
  module SoulsLogger
    class Configuration
      attr_accessor :logger

      def initialize
        @logger = nil
      end
    end

    class << self
      attr_writer :configuration
    end

    def self.configuration
      @configuration ||= Configuration.new
    end

    def self.configure
      yield(configuration)
    end

    def self.critical_log(message)
      entry = write_log(message)
      entry.critical!

      configuration.logger.write_entries(entry)
    end

    def self.warning_log(message)
      entry = write_log(message)
      entry.warning!

      configuration.logger.write_entries(entry)
    end

    def self.info_log(message)
      entry = write_log(message)
      entry.info!

      configuration.logger.write_entries(entry)
    end

    def self.write_log(message)
      entry = configuration.logger.entry
      entry.payload = "#{message}\n #{message.backtrace.join("\n")}"
      entry.log_name = "error"
      entry.resource.type = "cloud_run_revision"
      entry.resource.labels[:service_name] = "souls"
      entry.resource.labels[:revision_name] = Souls::VERSION

      entry
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
souls-1.10.0 lib/souls/app/utils/souls_logger.rb
souls-1.9.17 lib/souls/app/utils/souls_logger.rb
souls-1.9.16 lib/souls/app/utils/souls_logger.rb
souls-1.9.15 lib/souls/app/utils/souls_logger.rb
souls-1.9.14 lib/souls/app/utils/souls_logger.rb
souls-1.9.12 lib/souls/app/utils/souls_logger.rb