Class: RubySmart::SimpleLogger::Logger

Inherits:
Logger
  • Object
show all
Includes:
ActionView::Helpers::DateHelper, Extensions::Helper, Extensions::Logs, Extensions::Mask, Extensions::Processed, Extensions::Scene, Extensions::Severity, Extensions::SimpleLog, Extensions::Timer, Scenes
Defined in:
lib/ruby_smart/simple_logger/logger.rb

Constant Summary collapse

PAYLOAD_DATA_KEY =

defines a uniq key to parse the data

:__data__

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Logger

initializes a new Logger

Parameters:

  • args (Array)

    (,) OR () OR ()

  • args[Symbol,Array] (Hash)

    a customizable set of options

  • args[Hash] (Hash)

    a customizable set of options



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ruby_smart/simple_logger/logger.rb', line 49

def initialize(*args)
  opts = args.last.is_a?(Hash) ? args.pop : {}
  opts[:builtin] = args if args.length > 0

  # enhance options with device & formatter
  _opts_device!(opts)
  _opts_formatter!(opts)

  # initialize & set defaults by provided opts
  _opts_init!(opts)

  # initialize with a nil +logdev+ to prevent any nested +LogDevice+ creation.
  # we already arranged device & formatter to be able to respond to ther required methods
  super(nil)

  # set explicit after called super
  self.level = opts[:level]
  self.formatter = opts[:formatter]
  @logdev = _logdev(opts)
end

Instance Attribute Details

#logdevObject (readonly)

enable access to the logdev



39
40
41
# File 'lib/ruby_smart/simple_logger/logger.rb', line 39

def logdev
  @logdev
end

Instance Method Details

#level=(sev) ⇒ Object

overwrite level setter, to accept every available (also newly defined) Severity

Parameters:

  • sev (Numeric, String, Symbol)
    • severity to resolve


72
73
74
# File 'lib/ruby_smart/simple_logger/logger.rb', line 72

def level=(sev)
  @level = _level(sev)
end

#log_statsHash Originally defined in module Extensions::Logs

returns a hash with total amounts per logged type (key)

Returns:

  • (Hash)

#logsArray Originally defined in module Extensions::Logs

returns the logdev logs

Returns:

  • (Array)

#logs_to_hHash Originally defined in module Extensions::Logs

transforms the logs-array into a hash of logs, grouped by level (:error, :success, ...)

Returns:

  • (Hash)

    logs

#timer(action, key = :default, opts = {}) ⇒ Object Originally defined in module Extensions::Timer