Sha256: dc8f29f4118d77749b021103a038735b801b5afde9e0eecb6837433ec051dca2

Contents?: true

Size: 786 Bytes

Versions: 57

Compression:

Stored size: 786 Bytes

Contents

module Hydra #:nodoc:
  # Trace output when in verbose mode.
  module Trace
    module ClassMethods
      # Make a class traceable. Takes one parameter,
      # which is the prefix for the trace to identify this class
      def traceable(prefix = self.class.to_s)
        include Hydra::Trace::InstanceMethods
        class << self; attr_accessor :_traceable_prefix; end
        self._traceable_prefix = prefix
        $stdout.sync = true
      end
    end

    module InstanceMethods
      # Trace some output with the class's prefix and a newline.
      # Checks to ensure we're running verbosely.
      def trace(str)
        $stdout.write "#{Time.now.to_f} #{self.class._traceable_prefix}| #{str}\n" if @verbose
      end
    end
  end
end
Object.extend(Hydra::Trace::ClassMethods)

Version data entries

57 entries across 57 versions & 8 rubygems

Version Path
ngauthier-hydra-0.24.0 lib/hydra/trace.rb
nulogy-hydra-0.26.0 lib/hydra/trace.rb
arturop-hydra-0.25.0 lib/hydra/trace.rb
hydra-0.24.0 lib/hydra/trace.rb
justinf-hydra-0.23.8 lib/hydra/trace.rb
justinf-hydra-0.23.7 lib/hydra/trace.rb
justinf-hydra-0.23.6 lib/hydra/trace.rb
justinf-hydra-0.23.5 lib/hydra/trace.rb
justinf-hydra-0.23.4 lib/hydra/trace.rb
arturop-hydra-0.23.4 lib/hydra/trace.rb
sskirby-hydra-0.23.3 lib/hydra/trace.rb
hydra-0.23.3 lib/hydra/trace.rb
causes-hydra-0.21.0 lib/hydra/trace.rb
hydra-0.23.2 lib/hydra/trace.rb
hydra-0.23.1 lib/hydra/trace.rb
hydra-0.23.0 lib/hydra/trace.rb
hydra-0.22.2 lib/hydra/trace.rb
hydra-0.22.1 lib/hydra/trace.rb
hydra-0.22.0 lib/hydra/trace.rb
hydra-0.21.0 lib/hydra/trace.rb