Class: LogSnag::Log

Inherits:
EventBase show all
Defined in:
lib/logsnag/log.rb

Overview

Constructs and validates an event log

Constant Summary collapse

REQUIRED_KEYS =
%i[project channel event].freeze
ALLOWED_KEYS =
REQUIRED_KEYS + %i[
  user_id description icon notify tags parser timestamp
].freeze

Instance Attribute Summary

Attributes inherited from EventBase

#config, #data

Instance Method Summary collapse

Methods inherited from EventBase

#to_json

Constructor Details

#initialize(data, config) ⇒ LogSnag::Insight

Creates a new Log object. The data hash must include the following keys:

- :channel [String] The channel within the project to which the log belongs.
- :event [String] The name of the event.

The data hash may include the following keys:

- :user_id [String] The user ID of the user to be identified.
- :description [String] The description of the event.
- :icon [String] The icon to be displayed with the event.
- :notify [Boolean] Whether or not to send a push notification for the event.
- :tags [Hash] The tags to be associated with the event.
- :parser [String] The parser to be used for the event. One of "text" or "markdown".
- :timestamp [Numeric] The timestamp of the event (in Unix seconds).

Parameters:

  • data (Hash)

    The data to be sent to LogSnag.

  • config (LogSnag::Configuration)

    The configuration object.

Raises:

  • (ArgumentError)

    If the hash is missing required keys, has invalid keys, or has values of incorrect types.

See Also:



33
34
35
36
37
38
39
# File 'lib/logsnag/log.rb', line 33

def initialize(data, config)
  super(data, config)

  append_required_fields!
  compact_tags!
  validate_data
end