Class: ActiveStorage::LogSubscriber

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

Instance Method Summary collapse

Instance Method Details

#loggerObject



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

def logger
  ActiveStorage::Service.logger
end

#service_delete(event) ⇒ Object



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

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

#service_download(event) ⇒ Object



10
11
12
# File 'lib/active_storage/log_subscriber.rb', line 10

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

#service_exist(event) ⇒ Object



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

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

#service_upload(event) ⇒ Object



4
5
6
7
8
# File 'lib/active_storage/log_subscriber.rb', line 4

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



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

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