Class: ActiveStorage::LogSubscriber

Inherits:
ActiveSupport::LogSubscriber show all
Defined in:
activestorage/lib/active_storage/log_subscriber.rb

Constant Summary

Constants inherited from ActiveSupport::LogSubscriber

ActiveSupport::LogSubscriber::BLACK, ActiveSupport::LogSubscriber::BLUE, ActiveSupport::LogSubscriber::BOLD, ActiveSupport::LogSubscriber::CLEAR, ActiveSupport::LogSubscriber::CYAN, ActiveSupport::LogSubscriber::GREEN, ActiveSupport::LogSubscriber::MAGENTA, ActiveSupport::LogSubscriber::RED, ActiveSupport::LogSubscriber::WHITE, ActiveSupport::LogSubscriber::YELLOW

Instance Attribute Summary

Attributes inherited from ActiveSupport::Subscriber

#patterns

Instance Method Summary collapse

Methods inherited from ActiveSupport::LogSubscriber

#finish, flush_all!, log_subscribers, #start

Methods inherited from ActiveSupport::Subscriber

attach_to, detach_from, #finish, #initialize, method_added, #start, subscribers

Constructor Details

This class inherits a constructor from ActiveSupport::Subscriber

Instance Method Details

#loggerObject



41
42
43
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 41

def logger
  ActiveStorage.logger
end

#service_delete(event) ⇒ Object



19
20
21
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 19

def service_delete(event)
  info event, color("Deleted file from key: #{key_in(event)}", RED)
end

#service_delete_prefixed(event) ⇒ Object



23
24
25
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 23

def service_delete_prefixed(event)
  info event, color("Deleted files by key prefix: #{event.payload[:prefix]}", RED)
end

#service_download(event) ⇒ Object Also known as: service_streaming_download



13
14
15
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 13

def service_download(event)
  info event, color("Downloaded file from key: #{key_in(event)}", BLUE)
end

#service_exist(event) ⇒ Object



27
28
29
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 27

def service_exist(event)
  debug event, color("Checked if file exists at key: #{key_in(event)} (#{event.payload[:exist] ? "yes" : "no"})", BLUE)
end

#service_mirror(event) ⇒ Object



35
36
37
38
39
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 35

def service_mirror(event)
  message = "Mirrored file at key: #{key_in(event)}"
  message += " (checksum: #{event.payload[:checksum]})" if event.payload[:checksum]
  debug event, color(message, GREEN)
end

#service_upload(event) ⇒ Object



7
8
9
10
11
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 7

def service_upload(event)
  message = "Uploaded file to key: #{key_in(event)}"
  message += " (checksum: #{event.payload[:checksum]})" if event.payload[:checksum]
  info event, color(message, GREEN)
end

#service_url(event) ⇒ Object



31
32
33
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 31

def service_url(event)
  debug event, color("Generated URL for file at key: #{key_in(event)} (#{event.payload[:url]})", BLUE)
end