class Shrine::Plugins::Instrumentation::LogSubscriber

Logs received events.

Public Class Methods

call(event) click to toggle source

Entry point for logging.

# File lib/shrine/plugins/instrumentation.rb, line 242
def self.call(event)
  new.public_send(:"on_#{event.name}", event)
end

Public Instance Methods

on_delete(event) click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 282
def on_delete(event)
  log "Delete (#{event.duration}ms) – #{format(
    storage:  event[:storage],
    location: event[:location],
    uploader: event[:uploader],
  )}"
end
on_download(event) click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 256
def on_download(event)
  log "Download (#{event.duration}ms) – #{format(
    storage:          event[:storage],
    location:         event[:location],
    download_options: event[:download_options],
    uploader:         event[:uploader],
  )}"
end
on_exists(event) click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 274
def on_exists(event)
  log "Exists (#{event.duration}ms) – #{format(
    storage:  event[:storage],
    location: event[:location],
    uploader: event[:uploader],
  )}"
end
on_metadata(event) click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 290
def on_metadata(event)
  log "Metadata (#{event.duration}ms) – #{format(
    storage:  event[:storage],
    io:       event[:io].class,
    uploader: event[:uploader],
  )}"
end
on_open(event) click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 265
def on_open(event)
  log "Open (#{event.duration}ms) – #{format(
    storage:          event[:storage],
    location:         event[:location],
    download_options: event[:download_options],
    uploader:         event[:uploader],
  )}"
end
on_upload(event) click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 246
def on_upload(event)
  log "Upload (#{event.duration}ms) – #{format(
    storage:        event[:storage],
    location:       event[:location],
    io:             event[:io].class,
    upload_options: event[:upload_options],
    uploader:       event[:uploader],
  )}"
end

Private Instance Methods

format(properties = {}) click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 300
def format(properties = {})
  properties.inspect
end
log(message) click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 304
def log(message)
  logger.info(message)
end
logger() click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 308
def logger
  Shrine.logger
end