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.12.3 lib/souls/app/utils/souls_logger.rb
souls-1.12.2 lib/souls/app/utils/souls_logger.rb
souls-1.12.1 lib/souls/app/utils/souls_logger.rb
souls-1.12.0 lib/souls/app/utils/souls_logger.rb
souls-1.11.7 lib/souls/app/utils/souls_logger.rb
souls-1.11.6 lib/souls/app/utils/souls_logger.rb
souls-1.11.5 lib/souls/app/utils/souls_logger.rb
souls-1.11.4 lib/souls/app/utils/souls_logger.rb
souls-1.11.3 lib/souls/app/utils/souls_logger.rb
souls-1.11.2 lib/souls/app/utils/souls_logger.rb
souls-1.11.1 lib/souls/app/utils/souls_logger.rb
souls-1.11.0 lib/souls/app/utils/souls_logger.rb
souls-1.10.8 lib/souls/app/utils/souls_logger.rb
souls-1.10.7 lib/souls/app/utils/souls_logger.rb
souls-1.10.6 lib/souls/app/utils/souls_logger.rb
souls-1.10.5 lib/souls/app/utils/souls_logger.rb
souls-1.10.4 lib/souls/app/utils/souls_logger.rb
souls-1.10.3 lib/souls/app/utils/souls_logger.rb
souls-1.10.2 lib/souls/app/utils/souls_logger.rb
souls-1.10.1 lib/souls/app/utils/souls_logger.rb