Module: AtlasEngine::LogBase

Extended by:
T::Sig
Includes:
Kernel
Defined in:
app/helpers/atlas_engine/log_base.rb

Constant Summary collapse

TEST_TIMESTAMP =
T.let("timestamp", String)

Instance Method Summary collapse

Instance Method Details

#log_message(level, message, additional_params = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/atlas_engine/log_base.rb', line 12

def log_message(level, message, additional_params = {})
  params = {
    messages: [{
      level: level,
      source: self.class.name,
      message: message,
      timestamp: time,
    }.merge(additional_params)],
  }

  Rails.logger.send(level, params)
end

#timeObject



26
27
28
29
30
# File 'app/helpers/atlas_engine/log_base.rb', line 26

def time
  return TEST_TIMESTAMP if Rails.env.test?

  Time.current.utc.to_fs
end