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.



242
243
244
# File 'lib/shrine/plugins/instrumentation.rb', line 242

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

Instance Method Details

#on_delete(event) ⇒ Object



282
283
284
285
286
287
288
# 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) ⇒ Object



256
257
258
259
260
261
262
263
# 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) ⇒ Object



274
275
276
277
278
279
280
# 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) ⇒ Object



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

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

#on_open(event) ⇒ Object



265
266
267
268
269
270
271
272
# 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) ⇒ Object



246
247
248
249
250
251
252
253
254
# 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