Class: Hubbado::Log
- Inherits:
-
Object
show all
- Includes:
- Dependency
- Defined in:
- lib/hubbado/log.rb,
lib/hubbado/log/log.rb,
lib/hubbado/log/tags.rb,
lib/hubbado/log/logger.rb,
lib/hubbado/log/log_handler.rb,
lib/hubbado/log/configuration.rb,
lib/hubbado/log/controls/data.rb,
lib/hubbado/log/controls/message.rb,
lib/hubbado/log/controls/subject.rb,
lib/hubbado/log/controls/exception.rb,
lib/hubbado/log/controls/log_handler.rb
Defined Under Namespace
Modules: Controls
Classes: Configuration, LogHandler, Logger, Tags
Constant Summary
collapse
- SEVERITIES =
Ordered, because the level compares against them. trace is program flow, a message per
iteration; debug is the completion of a secondary operation, or a detail worth keeping;
info is the completion of the principal operation of a class or utility.
{ trace: 0, debug: 1, info: 2, warn: 3, error: 4, fatal: 5, unknown: 6 }.freeze
- STACKTRACE_SEVERITIES =
%i[warn error fatal unknown].freeze
- LEVEL_VARIABLE =
"LOG_LEVEL".freeze
- TAGS_VARIABLE =
"LOG_TAGS".freeze
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
19
20
21
|
# File 'lib/hubbado/log/log.rb', line 19
def config
@config
end
|
Class Method Details
.configuration {|@config| ... } ⇒ Object
21
22
23
24
25
|
# File 'lib/hubbado/log/log.rb', line 21
def configuration
yield @config
@loggers = nil
end
|
63
64
65
66
67
68
|
# File 'lib/hubbado/log/log.rb', line 63
def self.configure(receiver, attr_name: nil)
attr_name ||= :logger
instance = Logger.new(receiver.class.name, loggers)
receiver.public_send("#{attr_name}=", instance)
instance
end
|
.inherited(cls) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/hubbado/log/log.rb', line 43
def self.inherited(cls)
cls.class_exec do
dependency_module = Module.new do
define_singleton_method :included do |reciever_class|
reciever_class.class_exec do
::Dependency::Attribute.define(self, :logger, cls)
define_method :logger do
@logger ||= cls.configure self
end
end
end
end
const_set :Dependency, dependency_module
end
end
|
.log(*args, tag: nil, tags: nil) ⇒ Object
The keywords are named rather than swept up with the positionals: a method taking only
*args accepts no keywords, so Ruby would fold them into a trailing hash and they would
arrive as the message's data — which a handler hands to Rollbar as the exception.
38
39
40
|
# File 'lib/hubbado/log/log.rb', line 38
def log(*args, tag: nil, tags: nil)
logger.log(*args, tag: tag, tags: tags)
end
|
.logger ⇒ Object
31
32
33
|
# File 'lib/hubbado/log/log.rb', line 31
def logger
@logger = Logger.new('', loggers)
end
|
.loggers ⇒ Object
27
28
29
|
# File 'lib/hubbado/log/log.rb', line 27
def loggers
@loggers ||= config.loggers.map(&:new)
end
|