Sha256: b946d8ba4611a9fb775a31b499d4ca28fc29d3c6ba211127983e6c3c119b97fd

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

# Module for working with the [DataCite metadata schema](https://schema.datacite.org/meta/kernel-3/index.html)
module Datacite
  # Maps DataCite XML to Ruby objects
  module Mapping

    Dir.glob(File.expand_path('../mapping/*.rb', __FILE__)).sort.each(&method(:require))

    class << self
      attr_writer :log
    end

    # Gets the logger for the module. Default logger logs to `$stdout`.
    # @return [Logger] the logger
    def self.log
      self.log_device = $stdout unless @log
      @log
    end

    # Sets the log device. Defaults to `$stdout`
    # @param value [IO] the log device
    def self.log_device=(value)
      @log = new_logger(logdev: value)
    end

    private

    def self.new_logger(logdev:, level: Logger::DEBUG, shift_age: 10, shift_size: 1024 * 1024)
      logger = Logger.new(logdev, shift_age, shift_size)
      logger.level = level
      logger.formatter = proc do |severity, datetime, progname, msg|
        "#{datetime.to_time.utc} #{severity} -#{progname}- #{msg}\n"
      end
      logger
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
datacite-mapping-0.1.3 lib/datacite/mapping.rb
datacite-mapping-0.1.2 lib/datacite/mapping.rb
datacite-mapping-0.1.1 lib/datacite/mapping.rb
datacite-mapping-0.1.0 lib/datacite/mapping.rb