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.


238
239
240
# File 'lib/shrine/plugins/instrumentation.rb', line 238

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

Instance Method Details

#on_delete(event) ⇒ Object


278
279
280
281
282
283
284
# File 'lib/shrine/plugins/instrumentation.rb', line 278

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

#on_download(event) ⇒ Object


252
253
254
255
256
257
258
259
# File 'lib/shrine/plugins/instrumentation.rb', line 252

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


270
271
272
273
274
275
276
# File 'lib/shrine/plugins/instrumentation.rb', line 270

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

#on_metadata(event) ⇒ Object


286
287
288
289
290
291
292
# File 'lib/shrine/plugins/instrumentation.rb', line 286

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

#on_open(event) ⇒ Object


261
262
263
264
265
266
267
268
# File 'lib/shrine/plugins/instrumentation.rb', line 261

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


242
243
244
245
246
247
248
249
250
# File 'lib/shrine/plugins/instrumentation.rb', line 242

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