Class: Himari::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/himari/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issuer:, storage:, providers: [], log_output: $stdout, log_level: Logger::INFO, preserve_rack_logger: false, custom_templates: {}, custom_messages: {}, release_fragment: nil) ⇒ Config

Returns a new instance of Config.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/himari/config.rb', line 8

def initialize(issuer:, storage:, providers: [], log_output: $stdout, log_level: Logger::INFO, preserve_rack_logger: false, custom_templates: {}, custom_messages: {}, release_fragment: nil)
  @issuer = issuer
  @providers = providers
  @storage = storage

  @log_output = log_output
  @log_level = log_level
  @preserve_rack_logger = preserve_rack_logger

  @custom_messages = custom_messages
  @custom_templates = custom_templates
  @release_fragment = release_fragment
end

Instance Attribute Details

#custom_messagesObject (readonly)

Returns the value of attribute custom_messages.



22
23
24
# File 'lib/himari/config.rb', line 22

def custom_messages
  @custom_messages
end

#custom_templatesObject (readonly)

Returns the value of attribute custom_templates.



22
23
24
# File 'lib/himari/config.rb', line 22

def custom_templates
  @custom_templates
end

#issuerObject (readonly)

Returns the value of attribute issuer.



22
23
24
# File 'lib/himari/config.rb', line 22

def issuer
  @issuer
end

#preserve_rack_loggerObject (readonly)

Returns the value of attribute preserve_rack_logger.



22
23
24
# File 'lib/himari/config.rb', line 22

def preserve_rack_logger
  @preserve_rack_logger
end

#providersObject (readonly)

Returns the value of attribute providers.



22
23
24
# File 'lib/himari/config.rb', line 22

def providers
  @providers
end

#release_fragmentObject (readonly)

Returns the value of attribute release_fragment.



22
23
24
# File 'lib/himari/config.rb', line 22

def release_fragment
  @release_fragment
end

#storageObject (readonly)

Returns the value of attribute storage.



22
23
24
# File 'lib/himari/config.rb', line 22

def storage
  @storage
end

Instance Method Details

#loggerObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/himari/config.rb', line 24

def logger
  @logger ||= Logger.new(@log_output).tap do |l|
    l.level = @log_level
    l.formatter = proc do |severity, datetime, progname, msg|
      log = {time: datetime.xmlschema, severity: severity.to_s, pid: Process.pid}

      case msg
      when Himari::LogLine
        log[:message] = msg.message
        log[:data] = msg.data
      else
        log[:message] = msg.to_s
      end

      "#{JSON.generate(log)}\n"
    end
  end
end