Sha256: 728ae53fe63ae0d6b9e10fadb4b721f1e54059ba8d00cc4bb6aedd6c52115a33

Contents?: true

Size: 1.55 KB

Versions: 9

Compression:

Stored size: 1.55 KB

Contents

require "travis/surveillance/build"
require "travis/surveillance/job"
require "travis/surveillance/project"
require "travis/surveillance/surveyor"
require "travis/surveillance/version"

module Travis
  module Surveillance
    module Logger
      def self.log(data, &block)
        STDOUT.puts data
        yield if block_given?
      end
    end

    # Public: Allows the user to specify a logger for the log messages that Travis::Surveillance
    # produces.
    #
    # logger = The object you want logs to be sent too
    #
    # Examples
    #
    #   Travis::Surveillance.instrument_with(STDOUT.method(:puts))
    #   # => #<Method: IO#puts>
    #
    # Returns the logger object
    def self.instrument_with(logger)
      @logger = logger
    end

    # Internal: Top level log method for use by Travis::Surveillance
    #
    # data = Logging data (typically a hash)
    # blk  = block to execute
    #
    # Returns the response from calling the logger with the arguments
    def self.log(data, &blk)
      logger.call({ 'travis-surveillance' => true }.merge(data), &blk)
    end

    # Public: The logging location
    #
    # Returns an Object
    def self.logger
      @logger || Travis::Surveillance::Logger.method(:log)
    end

    # Public: Enable mocking mode
    #
    # Examples
    #
    #   Travis::Surveillance.mock!
    #   # => true
    def self.mock!
      @mock = true
    end

    # Public: Check if mocking is enabled
    #
    # Examples
    #
    #   Travis::Surveillance.mocking?
    #   # => false
    def self.mocking?
      @mock || false
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
travis-surveillance-0.0.9 lib/travis/surveillance.rb
travis-surveillance-0.0.8 lib/travis/surveillance.rb
travis-surveillance-0.0.7 lib/travis/surveillance.rb
travis-surveillance-0.0.6 lib/travis/surveillance.rb
travis-surveillance-0.0.5 lib/travis/surveillance.rb
travis-surveillance-0.0.4 lib/travis/surveillance.rb
travis-surveillance-0.0.3 lib/travis/surveillance.rb
travis-surveillance-0.0.2 lib/travis/surveillance.rb
travis-surveillance-0.0.1 lib/travis/surveillance.rb