Class: ChiliLogger

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/chili_logger.rb,
lib/brokers/sqs_broker.rb,
lib/brokers/main_broker.rb,
lib/chili_logger/version.rb,
lib/current_log_accessor.rb,
lib/brokers/rabbit_broker.rb,
lib/helpers/values/default.rb,
lib/message_writer/message_writer.rb,
lib/helpers/values/secrets/secrets.rb,
lib/message_writer/aws_ops_metadata.rb,
lib/errors/error_messages/config_error.rb,
lib/helpers/values/type_uniformizer/desc.rb,
lib/helpers/values/type_uniformizer/user.rb,
lib/helpers/logs_coverage/coverage_writer.rb,
lib/helpers/values/secrets/aws_secrets_manager.rb,
lib/helpers/values/type_uniformizer/main_content.rb,
lib/unpublished_logs_manager/unpublished_logs_manager.rb,
lib/errors/logging_error_handler/logging_error_handler.rb

Overview

class for centralizing Creative’s logging logic

Defined Under Namespace

Modules: AWS, Values Classes: AwsOpsMetadata, ConfigError, CoverageWriter, CurrentLogAccessor, LoggingErrorHandler, MainBroker, MessageWriter, RabbitBroker, UnpublishedLogsManager

Constant Summary collapse

VERSION =
'0.1.2'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChiliLogger

Returns a new instance of ChiliLogger.



21
22
23
24
25
26
# File 'lib/chili_logger.rb', line 21

def initialize
  @default = ChiliLogger::Values::Default.new
  @user_uniformizer = ChiliLogger::Values::TypeUniformizer::User.new
  @desc_uniformizer = ChiliLogger::Values::TypeUniformizer::Desc.new
  @main_content_uniformizer = ChiliLogger::Values::TypeUniformizer::MainContent.new
end

Instance Attribute Details

#deactivatedObject

Returns the value of attribute deactivated.



16
17
18
# File 'lib/chili_logger.rb', line 16

def deactivated
  @deactivated
end

#msg_brokerObject (readonly)

Returns the value of attribute msg_broker.



15
16
17
# File 'lib/chili_logger.rb', line 15

def msg_broker
  @msg_broker
end

Instance Method Details

#config(config) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/chili_logger.rb', line 28

def config(config)
  @deactivated = config[:deactivated] || false # ChilLogger can be deactivated for test environents

  config_logging_error_handler(config)
  config_msg_writer(config)
  config_msg_broker(config)
  config_unpublished_logs_manager

  @current_log_accessor = CurrentLogAccessor.new(@msg_broker, @msg_writer)
end

#current_logObject



39
40
41
# File 'lib/chili_logger.rb', line 39

def current_log
  @current_log_accessor
end

#publish_instant_log(**options) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/chili_logger.rb', line 53

def publish_instant_log(**options)
  # enforces that all attributes have valid primitive types
  if options
    options[:desc] = @desc_uniformizer.desc(options[:desc])
    options[:user] = @user_uniformizer.user(options[:user])
    options[:main_content] = @main_content_uniformizer.main_content(options[:main_content])
  end

  message = @msg_writer.write(options)
  @msg_broker.publish(message)
end

#republish_unpublished_logsObject



65
66
67
# File 'lib/chili_logger.rb', line 65

def republish_unpublished_logs
  @unpublished_logs_manager.republish
end

#start_new_log(**options) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/chili_logger.rb', line 43

def start_new_log(**options)
  current_log.clear_log_info

  current_log.update_desc(options[:desc])
  current_log.update_user(options[:user])
  current_log.update_main_content(options[:main_content])

  current_log
end