Module: Tailog::WatchMethods
- Included in:
- Tailog
- Defined in:
- lib/tailog/watch_methods.rb
Class Attribute Summary collapse
-
.inject_options ⇒ Object
Returns the value of attribute inject_options.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.inject_options ⇒ Object
Returns the value of attribute inject_options.
9 10 11 |
# File 'lib/tailog/watch_methods.rb', line 9 def @inject_options end |
Class Method Details
.logger ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tailog/watch_methods.rb', line 11 def logger return @logger if @logger @logger = Logger.new(File.join Tailog.log_path, "watch_methods.log") @logger.formatter = proc do |severity, datetime, progname, | content = "" content << "[#{datetime.strftime("%Y-%m-%d %H:%M:%S")}]" content << "[#{Tailog.request_id}]" if Tailog.request_id content << " #{severity.rjust(5)}" content << " (#{progname})" if progname content << ": #{.gsub(/\n\s*/, " ")}" content << "\n" content end @logger end |
Instance Method Details
#cleanup(targets) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/tailog/watch_methods.rb', line 54 def cleanup targets WatchMethods.logger.debug "Cleanup #{targets}." targets.each do |target| if target.include? "#" cleanup_instance_method target elsif target.include? "." cleanup_class_method target else cleanup_constant target end end end |
#inject(targets, options = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/tailog/watch_methods.rb', line 36 def inject targets, = {} WatchMethods.logger.debug "Inject #{targets} with options #{}." = Tailog::WatchMethods..merge() targets.each do |target| begin if target.include? "#" inject_instance_method target, elsif target.include? "." inject_class_method target, else inject_constant target, end rescue => error WatchMethods.logger.error "Inject #{target} FAILED: #{error.class}: #{error.}." end end end |