Class: Shrine::Plugins::Instrumentation::LogSubscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/shrine/plugins/instrumentation.rb

Overview

Logs received events.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(event) ⇒ Object

Entry point for logging.



235
236
237
# File 'lib/shrine/plugins/instrumentation.rb', line 235

def self.call(event)
  new.public_send(:"on_#{event.name}", event)
end

Instance Method Details

#on_delete(event) ⇒ Object



266
267
268
269
270
271
272
# File 'lib/shrine/plugins/instrumentation.rb', line 266

def on_delete(event)
  log "Delete (#{event.duration}ms) – #{format(
    storage:  event[:storage],
    location: event[:location],
    uploader: event[:uploader],
  )}"
end

#on_download(event) ⇒ Object



249
250
251
252
253
254
255
256
# File 'lib/shrine/plugins/instrumentation.rb', line 249

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) ⇒ Object



258
259
260
261
262
263
264
# File 'lib/shrine/plugins/instrumentation.rb', line 258

def on_exists(event)
  log "Exists (#{event.duration}ms) – #{format(
    storage:  event[:storage],
    location: event[:location],
    uploader: event[:uploader],
  )}"
end

#on_metadata(event) ⇒ Object



274
275
276
277
278
279
280
# File 'lib/shrine/plugins/instrumentation.rb', line 274

def (event)
  log "Metadata (#{event.duration}ms) – #{format(
    storage:  event[:storage],
    io:       event[:io].class,
    uploader: event[:uploader],
  )}"
end

#on_upload(event) ⇒ Object



239
240
241
242
243
244
245
246
247
# File 'lib/shrine/plugins/instrumentation.rb', line 239

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