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.



244
245
246
# File 'lib/shrine/plugins/instrumentation.rb', line 244

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

Instance Method Details

#on_delete(event) ⇒ Object



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

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

#on_download(event) ⇒ Object



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

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



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

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

#on_metadata(event) ⇒ Object



292
293
294
295
296
297
298
# File 'lib/shrine/plugins/instrumentation.rb', line 292

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

#on_open(event) ⇒ Object



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

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



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

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