Sha256: b22da13a8fc457164f041b88e50cb828955f619e2d897bcd6d7bb3ec19175fe7

Contents?: true

Size: 1.12 KB

Versions: 12

Compression:

Stored size: 1.12 KB

Contents

module Sso
  # One thing tha bugs me is when I cannot see which part of the code caused a log message.
  # This mixin will include the current class name as Logger `progname` so you can show that it in your logfiles.
  #
  module Logging
    extend ActiveSupport::Concern

    module ClassMethods
      def debug(&block)
        logger && logger.debug(progname, &block)
      end

      def info(&block)
        logger && logger.info(progname, &block)
      end

      def warn(&block)
        logger && logger.warn(progname, &block)
      end

      def error(&block)
        logger && logger.error(progname, &block)
      end

      def fatal(&block)
        logger && logger.fatal(progname, &block)
      end

      def progname
        self.to_s
      end

      def logger
        Rails.logger
      end
    end #class_methods

    def debug(&block)
      self.class.debug(&block)
    end

    def info(&block)
      self.class.info(&block)
    end

    def warn(&block)
      self.class.warn(&block)
    end

    def error(&block)
      self.class.error(&block)
    end

    def fatal(&block)
      self.class.fatal(&block)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
doorkeeper_sso-0.4.9 lib/sso/logging.rb
doorkeeper_sso-0.4.8 lib/sso/logging.rb
doorkeeper_sso-0.4.6 lib/sso/logging.rb
doorkeeper_sso-0.4.3 lib/sso/logging.rb
doorkeeper_sso-0.4.1 lib/sso/logging.rb
doorkeeper_sso-0.4.0 lib/sso/logging.rb
doorkeeper_sso-0.2.7 lib/sso/logging.rb
doorkeeper_sso-0.2.6 lib/sso/logging.rb
doorkeeper_sso-0.2.5 lib/sso/logging.rb
doorkeeper_sso-0.2.3 lib/sso/logging.rb
doorkeeper_sso-0.2.2 lib/sso/logging.rb
doorkeeper_sso-0.2.0 lib/sso/logging.rb