Class: Flame::RavenContext

Inherits:
Object
  • Object
show all
Extended by:
Memery
Includes:
Memery
Defined in:
lib/flame/raven_context.rb,
lib/flame/raven_context/version.rb

Overview

Class for request context initialization

Constant Summary collapse

DEFAULT_LOGGERS =
{
	puma: {
		level: :error
	}.freeze,
	server: {
		level: :error
	}.freeze,
	not_found: {
		level: :warning,
		message: -> { "404: #{@controller.request.path}" }
	}.freeze,
	translations: {
		level: :error,
		message: -> { "Translation missing: #{@extra[:key]}" }
	}.freeze,
	validation_errors: {
		level: :warning,
		message: -> { "Validation errors: #{@extra[:form_class]}" }
	}.freeze
}.freeze
VERSION =
'0.1.2'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sentry_logger, controller: nil, env: controller&.request&.env, **extra) ⇒ RavenContext

Returns a new instance of RavenContext.



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/flame/raven_context.rb', line 47

def initialize(
	sentry_logger, controller: nil, env: controller&.request&.env, **extra
)
	@sentry_logger = sentry_logger
	@controller = controller
	@env = env
	@extra = extra
	@logger = self.class.loggers[@sentry_logger]
	@exception = @extra.delete(:exception) || instance_exec(&@logger[:message])
	@extra[:sql] = exception.sql if exception.respond_to? :sql
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



45
46
47
# File 'lib/flame/raven_context.rb', line 45

def exception
  @exception
end