Sha256: dcbb127148ed7e1636dfa531e422ceeeb344d251b089319f5405dc4e9427e8d5

Contents?: true

Size: 893 Bytes

Versions: 222

Compression:

Stored size: 893 Bytes

Contents

module Rails
  module Generator
    class SimpleLogger # :nodoc:
      attr_reader :out
      attr_accessor :quiet

      def initialize(out = $stdout)
        @out = out
        @quiet = false
        @level = 0
      end

      def log(status, message, &block)
        @out.print("%12s  %s%s\n" % [status, '  ' * @level, message]) unless quiet
        indent(&block) if block_given?
      end

      def indent(&block)
        @level += 1
        if block_given?
          begin
            block.call
          ensure
            outdent
          end
        end
      end

      def outdent
        @level -= 1
        if block_given?
          begin
            block.call
          ensure
            indent
          end
        end
      end

      private
        def method_missing(method, *args, &block)
          log(method.to_s, args.first, &block)
        end
    end
  end
end

Version data entries

222 entries across 221 versions & 25 rubygems

Version Path
rails-2.3.18 lib/rails_generator/simple_logger.rb
rails_csi-2.3.5.p8 lib/rails_generator/simple_logger.rb
rails-2.3.17 lib/rails_generator/simple_logger.rb
rails_csi-2.3.5.p7 lib/rails_generator/simple_logger.rb
rails_csi-2.3.5.p6 lib/rails_generator/simple_logger.rb
rails-2.3.16 lib/rails_generator/simple_logger.rb
rails-2.3.15 lib/rails_generator/simple_logger.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rails-2.3.14/lib/rails_generator/simple_logger.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/rails-2.3.12/lib/rails_generator/simple_logger.rb
rails-2.3.14 lib/rails_generator/simple_logger.rb
kajam-1.0.3.rc2 vendor/rails/railties/lib/rails_generator/simple_logger.rb
rails-2.3.12 lib/rails_generator/simple_logger.rb
radiant-1.0.0.rc2 vendor/rails/railties/lib/rails_generator/simple_logger.rb
radiant-1.0.0.rc1 vendor/rails/railties/lib/rails_generator/simple_logger.rb
webroar-0.5.0 src/admin_panel/vendor/rails/railties/lib/rails_generator/simple_logger.rb
rails-2.3.11 lib/rails_generator/simple_logger.rb
radiantcms-couchrest_model-0.2.4 vendor/rails/railties/lib/rails_generator/simple_logger.rb
radiantcms-couchrest_model-0.2.2 vendor/rails/railties/lib/rails_generator/simple_logger.rb
radiantcms-couchrest_model-0.2.1 vendor/rails/railties/lib/rails_generator/simple_logger.rb
radiantcms-couchrest_model-0.2 vendor/rails/railties/lib/rails_generator/simple_logger.rb