Class: GoogleLogger::Loggers::LocalLogger

Inherits:
Base
  • Object
show all
Defined in:
lib/google_logger/loggers/local_logger.rb

Constant Summary collapse

SEVERITY_MAPPING =
{
  DEFAULT: :info,
  DEBUG: :debug,
  INFO: :info,
  NOTICE: :info,
  WARNING: :warn,
  ERROR: :error,
  CRITICAL: :fatal,
  ALERT: :fatal,
  EMERGENCY: :fatal
}.freeze

Instance Method Summary collapse

Instance Method Details

#build_entry(payload, entry_args = {}) ⇒ Hash

Builds a new entry

Parameters:

  • payload (String, Hash)

    content of the log

  • entry_args (Hash) (defaults to: {})

    arguments which would normally be passed to google entry

Returns:

  • (Hash)

    entry with payload and default resource configuration



26
27
28
29
# File 'lib/google_logger/loggers/local_logger.rb', line 26

def build_entry(payload, entry_args = {})
  entry_args[:payload] = payload
  entry_args
end

#write_entry(entry) ⇒ Object

Writes an entry to google cloud

return [Boolean] ‘true` if the entry was successfully written

Parameters:

  • entry (Hash)

    entry to be written to google cloud



36
37
38
39
40
41
# File 'lib/google_logger/loggers/local_logger.rb', line 36

def write_entry(entry)
  log_level = SEVERITY_MAPPING[entry[:severity]] || :unknown
  configuration.local_logger.public_send(log_level, entry.inspect)

  true
end