Class: Logput::Adapters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/logput/adapters/base.rb

Overview

Base class from which all adapters inherit

Direct Known Subclasses

Logger, TaggedLogging

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ Base

Initialize



8
9
10
# File 'lib/logput/adapters/base.rb', line 8

def initialize(logger)
  @logger = logger
end

Class Method Details

.handles?(_logger) ⇒ Boolean

Placeholder for handles? method to be overridden when subclassed

Parameters:

  • _logger (Class)

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/logput/adapters/base.rb', line 23

def self.handles?(_logger)
  raise NotImplementedError
end

.register(adapter) ⇒ Object

Registers a new adapter

Parameters:

  • adapter (Symbol)

    The name of the adapter



15
16
17
18
# File 'lib/logput/adapters/base.rb', line 15

def self.register(adapter)
  raise "Already Registered :#{adapter}" if Logput::Adapters.registered_adapters[adapter]
  Logput::Adapters.registered_adapters[adapter] = self
end

Instance Method Details

#pathString

Placeholder for path method to be overridden when subclassed

Returns:

  • (String)

    path

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/logput/adapters/base.rb', line 29

def path
  raise NotImplementedError
end

#path_overrideString

Enable overriding of the path with an environment variable

Returns:

  • (String)

    path



35
36
37
38
39
# File 'lib/logput/adapters/base.rb', line 35

def path_override
  return unless directory && filename

  "#{directory}/#{filename}.log"
end