Sha256: a4ccd49a14f6f3a9cc60a3230b16830e13a78c94e0f03578d4f47c1cc14f494c
Contents?: true
Size: 973 Bytes
Versions: 1
Compression:
Stored size: 973 Bytes
Contents
module Hydra #:nodoc: # Trace output when in verbose mode. module Trace REMOTE_IDENTIFIER = 'REMOTE' 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) return unless @verbose remote_info = @remote ? "#{REMOTE_IDENTIFIER} #{@remote} " : '' str = str.gsub /\n/, "\n#{remote_info}" $stdout.write "#{Time.now.to_f} #{remote_info}#{self.class._traceable_prefix}| #{str}\n" end end end end Object.extend(Hydra::Trace::ClassMethods)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sskirby-hydra-0.21.0 | lib/hydra/trace.rb |