Sha256: 770d7f1856005074f6f5b06056501a530f0c1530bec00b262ff941df6fe3b89c

Contents?: true

Size: 1.24 KB

Versions: 12

Compression:

Stored size: 1.24 KB

Contents

module Savon

  # = Savon::Logger
  #
  # Savon::Logger can be mixed into classes to provide logging behavior.
  #
  # By default, the Logger mixin uses {Ruby's Logger}[http://ruby-doc.org/stdlib/libdoc/logger/rdoc/]
  # from the standard library, a log level of :debug and is pointing to STDOUT.
  module Logger

    module ClassMethods

      # Sets whether to log.
      def log=(log)
        @log = log
      end

      # Returns whether to log. Defaults to +true+.
      def log?
        @log != false
      end

      # Sets the logger.
      def logger=(logger)
        @logger = logger
      end

      # Returns the logger. Defaults to an instance of +Logger+ writing to STDOUT.
      def logger
        @logger ||= ::Logger.new STDOUT
      end

      # Sets the log level.
      def log_level=(log_level)
        @log_level = log_level
      end

      # Returns the log level. Defaults to +debug+.
      def log_level
        @log_level ||= :debug
      end

    end

    # Extends the class including this module with its ClassMethods.
    def self.included(base)
      base.extend ClassMethods
    end

    # Logs a given +message+.
    def log(message)
      self.class.logger.send self.class.log_level, message if self.class.log?
    end

  end
end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
johnreitano-savon-0.7.7.5 lib/savon/logger.rb
johnreitano-savon-0.7.7.4 lib/savon/logger.rb
johnreitano-savon-0.7.7.3 lib/savon/logger.rb
johnreitano-savon-0.7.7.2 lib/savon/logger.rb
pyu-savon-0.7.9.3 lib/savon/logger.rb
johnreitano-savon-0.7.7.1 lib/savon/logger.rb
hoopla-savon-0.7.9 lib/savon/logger.rb
savon-0.7.9 lib/savon/logger.rb
savon-0.7.8 lib/savon/logger.rb
savon-0.7.7 lib/savon/logger.rb
hoopla-savon-0.7.6 lib/savon/logger.rb
savon-0.7.6 lib/savon/logger.rb