Module: Ant::Logger::LogMethods
- Extended by:
- DRY::ResourceInjector
- Included in:
- Ant::Logger
- Defined in:
- lib/ant/logger/log_methods.rb
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
- #log_alert(description:, tagging_group:, tagging_sev:, tagging_org:) ⇒ Object
- #log_debug(msg, data = {}) ⇒ Object
- #log_error(msg, data = {}) ⇒ Object
- #log_fatal(msg, data = {}) ⇒ Object
- #log_info(msg, data = {}) ⇒ Object
- #log_metric(metric:, amount:, group: nil, time: nil) ⇒ Object
- #log_raw(severity, msg, data, debug = {}) ⇒ Object
- #log_warn(msg, data = {}) ⇒ Object
Class Method Details
.global_config ⇒ Object
8 9 10 |
# File 'lib/ant/logger/log_methods.rb', line 8 def self.global_config LogMethods.resource(:global_config) end |
.global_config=(config) ⇒ Object
12 13 14 |
# File 'lib/ant/logger/log_methods.rb', line 12 def self.global_config=(config) LogMethods.register(:global_config, config) end |
Instance Method Details
#config ⇒ Object
55 56 57 58 59 |
# File 'lib/ant/logger/log_methods.rb', line 55 def config self.class.respond_to?(:resource) ? self.class.resource(:log_config) : LogMethods.global_config rescue StandardError => _e global_config end |
#log_alert(description:, tagging_group:, tagging_sev:, tagging_org:) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/ant/logger/log_methods.rb', line 41 def log_alert(description:, tagging_group:, tagging_sev:, tagging_org:) log_fatal('Alert Triggered', description: description, group: tagging_group, severity: tagging_sev, response_team: tagging_org) end |
#log_debug(msg, data = {}) ⇒ Object
32 33 34 |
# File 'lib/ant/logger/log_methods.rb', line 32 def log_debug(msg, data = {}) log_raw(:debug, msg, data) end |
#log_error(msg, data = {}) ⇒ Object
24 25 26 |
# File 'lib/ant/logger/log_methods.rb', line 24 def log_error(msg, data = {}) log_raw(:error, msg, data, data[:debug]) end |
#log_fatal(msg, data = {}) ⇒ Object
28 29 30 |
# File 'lib/ant/logger/log_methods.rb', line 28 def log_fatal(msg, data = {}) log_raw(:fatal, msg, data, data[:debug]) end |
#log_info(msg, data = {}) ⇒ Object
16 17 18 |
# File 'lib/ant/logger/log_methods.rb', line 16 def log_info(msg, data = {}) log_raw(:info, msg, data, data[:debug]) end |
#log_metric(metric:, amount:, group: nil, time: nil) ⇒ Object
36 37 38 39 |
# File 'lib/ant/logger/log_methods.rb', line 36 def log_metric(metric:, amount:, group: nil, time: nil) log_info('Metric', metric: metric, value: amount, group: group, time: time) end |
#log_raw(severity, msg, data, debug = {}) ⇒ Object
49 50 51 52 53 |
# File 'lib/ant/logger/log_methods.rb', line 49 def log_raw(severity, msg, data, debug = {}) sev = Config::SEVERITIES[severity.to_s] = config.merge_params(msg, data, debug, severity) config.logger.add(sev, , self.class.name) end |
#log_warn(msg, data = {}) ⇒ Object
20 21 22 |
# File 'lib/ant/logger/log_methods.rb', line 20 def log_warn(msg, data = {}) log_raw(:warn, msg, data, data[:debug]) end |