123456789_123456789_123456789_123456789_123456789_

Class: ActiveStorage::LogSubscriber

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActiveSupport::EventReporter::LogSubscriber
Defined in: activestorage/lib/active_storage/log_subscriber.rb

Constant Summary

::ActiveSupport::ColorizeLogging - Included

BLACK, BLUE, CYAN, GREEN, MAGENTA, MODES, RED, WHITE, YELLOW

::ActiveSupport::EventReporter::LogSubscriber - Inherited

LEVEL_CHECKS

Class Attribute Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Class Method Details

.default_logger

[ GitHub ]

  
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 58

def self.default_logger
  ActiveStorage.logger
end

Instance Method Details

#debug(event, colored_message) (private)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 67

def debug(event, colored_message)
  super log_prefix_for_service(event) + colored_message
end

#info(event, colored_message) (private)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 63

def info(event, colored_message)
  super log_prefix_for_service(event) + colored_message
end

#key_in(event) (private)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 75

def key_in(event)
  event[:payload][:key]
end

#log_prefix_for_service(event) (private)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 71

def log_prefix_for_service(event)
  color "  #{event[:payload][:service]} Storage (#{event[:payload][:duration_ms].round(1)}ms) ", CYAN
end

#preview(event)

[ GitHub ]

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

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

#service_delete(event)

[ GitHub ]

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

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

#service_delete_prefixed(event)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 36

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

#service_download(event)

[ GitHub ]

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

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

#service_exist(event)

[ GitHub ]

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

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)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 51

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_streaming_download(event)

[ GitHub ]

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

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

#service_upload(event)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 9

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)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/log_subscriber.rb', line 46

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