Class: OctocatalogDiff::API::V1::Common

Inherits:
Object
  • Object
show all
Defined in:
lib/octocatalog-diff/api/v1/common.rb

Overview

Common functions for API v1

Class Method Summary collapse

Class Method Details

.logger_from_options(options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/octocatalog-diff/api/v1/common.rb', line 8

def self.logger_from_options(options)
  # If logger is not provided, create an object that can have messages written to it.
  # There won't be a way to access these messages, so if you want to log messages, then
  # provide that logger!
  logger = options[:logger] || Logger.new(StringIO.new)

  # We can't keep :logger in the options due to marshal/unmarshal as part of parallelization.
  pass_opts = options.dup
  pass_opts.delete(:logger)

  # Return cleaned options and logger
  [pass_opts, logger]
end