Class: Lenjador

Inherits:
Object
  • Object
show all
Defined in:
lib/lenjador.rb,
lib/lenjador/utils.rb,
lib/lenjador/adapters.rb,
lib/lenjador/null_logger.rb,
lib/lenjador/preprocessors.rb,
lib/lenjador/adapters/stdout_adapter.rb,
lib/lenjador/preprocessors/blacklist.rb,
lib/lenjador/preprocessors/whitelist.rb,
lib/lenjador/adapters/stdout_json_adapter.rb,
lib/lenjador/preprocessors/strategies/mask.rb,
lib/lenjador/preprocessors/strategies/prune.rb,
lib/lenjador/preprocessors/json_pointer_trie.rb

Defined Under Namespace

Modules: Adapters, Preprocessors, Utils Classes: NullLogger

Constant Summary collapse

Severity =
::Logger::Severity
SEV_LABEL =
%w[debug info warn error fatal any].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter, level, preprocessors) ⇒ Lenjador

Returns a new instance of Lenjador.



25
26
27
28
29
# File 'lib/lenjador.rb', line 25

def initialize(adapter, level, preprocessors)
  @adapter = adapter
  @level = level
  @preprocessors = preprocessors
end

Class Method Details

.build(service_name, logger_config, preprocessors_config = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/lenjador.rb', line 13

def self.build(service_name, logger_config, preprocessors_config = {})
  logger_config ||= {}

  preprocessors = preprocessors_config.map do |type, arguments|
    Preprocessors.get(type.to_s, arguments || {})
  end
  adapter = Adapters.get(service_name, logger_config)
  level = SEV_LABEL.index(logger_config.fetch(:level, 'debug'))

  new(adapter, level, preprocessors)
end

Instance Method Details

#debug(*args, &block) ⇒ Object



31
32
33
# File 'lib/lenjador.rb', line 31

def debug(*args, &block)
  log(Severity::DEBUG, *args, &block)
end

#debug?Boolean

Returns:

  • (Boolean)


51
# File 'lib/lenjador.rb', line 51

def debug?; @level <= Severity::DEBUG; end

#error(*args, &block) ⇒ Object



43
44
45
# File 'lib/lenjador.rb', line 43

def error(*args, &block)
  log(Severity::ERROR, *args, &block)
end

#error?Boolean

Returns:

  • (Boolean)


57
# File 'lib/lenjador.rb', line 57

def error?; @level <= Severity::ERROR; end

#fatal(*args, &block) ⇒ Object



47
48
49
# File 'lib/lenjador.rb', line 47

def fatal(*args, &block)
  log(Severity::FATAL, *args, &block)
end

#fatal?Boolean

Returns:

  • (Boolean)


59
# File 'lib/lenjador.rb', line 59

def fatal?; @level <= Severity::FATAL; end

#info(*args, &block) ⇒ Object



35
36
37
# File 'lib/lenjador.rb', line 35

def info(*args, &block)
  log(Severity::INFO, *args, &block)
end

#info?Boolean

Returns:

  • (Boolean)


53
# File 'lib/lenjador.rb', line 53

def info?; @level <= Severity::INFO; end

#warn(*args, &block) ⇒ Object



39
40
41
# File 'lib/lenjador.rb', line 39

def warn(*args, &block)
  log(Severity::WARN, *args, &block)
end

#warn?Boolean

Returns:

  • (Boolean)


55
# File 'lib/lenjador.rb', line 55

def warn?; @level <= Severity::WARN; end