Module: RubySmart::SimpleLogger::Extensions::SimpleLog::InstanceMethods
- Defined in:
- lib/ruby_smart/simple_logger/extensions/simple_log.rb
Instance Method Summary collapse
-
#ignore_payload? ⇒ Boolean
returns true if no payload should be created - instead the data will be send directly to the logdev forces the simple_log method to prevent building payloads from schemes - it just forwards the level & data to the logdev.
-
#ignore_tagged? ⇒ Boolean
returns true if no tags should be created - instead the data will be send directly to the logdev forces the simple_log method to prevent building tags from opts.
-
#inspector ⇒ Symbol?
resolve an inspector method for data inspection.
-
#simple_log(data, opts = {}) ⇒ Boolean
Acts as the MAIN logging method and sends the data to the device - checks provided level before logging - creates & formats payload.
Instance Method Details
#ignore_payload? ⇒ Boolean
returns true if no payload should be created - instead the data will be send directly to the logdev forces the simple_log method to prevent building payloads from schemes - it just forwards the level & data to the logdev
81 82 83 |
# File 'lib/ruby_smart/simple_logger/extensions/simple_log.rb', line 81 def ignore_payload? !!@ignore_payload end |
#ignore_tagged? ⇒ Boolean
returns true if no tags should be created - instead the data will be send directly to the logdev forces the simple_log method to prevent building tags from opts
89 90 91 |
# File 'lib/ruby_smart/simple_logger/extensions/simple_log.rb', line 89 def ignore_tagged? !!@ignore_tagged end |
#inspector ⇒ Symbol?
resolve an inspector method for data inspection
95 96 97 98 99 100 101 102 103 |
# File 'lib/ruby_smart/simple_logger/extensions/simple_log.rb', line 95 def inspector # return or resolve inspector @inspector ||= if self.class.inspector == :auto # provide awesome_print support Object.respond_to?(:ai) ? :ai : :inspect else self.class.inspector || :inspect end end |
#simple_log(data, opts = {}) ⇒ Boolean
Acts as the MAIN logging method and sends the data to the device
- checks provided level before logging
- creates & formats payload
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ruby_smart/simple_logger/extensions/simple_log.rb', line 46 def simple_log(data, opts = {}) # resolve & check level level = _level(opts[:level]) return false if level < self.level # prevents data from being transformed into payload if ignore_payload? || opts[:payload].is_a?(FalseClass) # prevent logging nil data return false if data.nil? add level, _parse_data(data, opts) return true end # create a default payload, if nothing was provided # :_ -> alias for log data opts[:payload] ||= [self.class::PAYLOAD_DATA_KEY] # create a default mask, if nothing was provided opts[:mask] ||= self.mask # create payloads and log each payload # returns the payload boolean result _payloads(opts.delete(:payload), opts, data) do |p| add level, p end # returns true as logging result true end |