Module: Pvectl::Commands::Logs::ResourceHandler Abstract

Included in:
Handlers::Journal, Handlers::Syslog, Handlers::TaskDetail, Handlers::TaskLogs
Defined in:
lib/pvectl/commands/logs/resource_handler.rb

Overview

This module is abstract.

Include in handler class and implement required methods.

Interface module for Logs command handlers.

Each handler fetches log data from a specific source (task list, syslog, journal, or task detail) and returns an appropriate presenter.

Examples:

Implementing a handler

class SyslogHandler
  include Logs::ResourceHandler

  def list(node:, limit: 50, **_)
    repository.list(node: node, limit: limit)
  end

  def presenter
    Presenters::SyslogEntry.new
  end
end

Instance Method Summary collapse

Instance Method Details

#list(**options) ⇒ Array<Object>

Lists log entries with filtering options.

Parameters:

  • options (Hash)

    keyword arguments specific to each handler

Returns:

  • (Array<Object>)

    collection of model objects

Raises:

  • (NotImplementedError)

    if not implemented by including class



32
33
34
# File 'lib/pvectl/commands/logs/resource_handler.rb', line 32

def list(**options)
  raise NotImplementedError, "#{self.class}#list must be implemented"
end

#presenterPresenters::Base

Returns the presenter for this log type.

Returns:

Raises:

  • (NotImplementedError)

    if not implemented by including class



40
41
42
# File 'lib/pvectl/commands/logs/resource_handler.rb', line 40

def presenter
  raise NotImplementedError, "#{self.class}#presenter must be implemented"
end