Class: BoringMetrics::LogMethods

Inherits:
Object
  • Object
show all
Defined in:
lib/boringmetrics/log_methods.rb

Overview

Methods for sending logs

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ LogMethods

Initialize the logs API

Parameters:



9
10
11
# File 'lib/boringmetrics/log_methods.rb', line 9

def initialize(client)
  @client = client
end

Instance Method Details

#send(log) ⇒ void

This method returns an undefined value.

Send a single log event

Parameters:

  • log (Hash)

    The log event to send

Options Hash (log):

  • :type (String)

    The type of log (default: “log”)

  • :level (String)

    The log level (trace, debug, info, warn, error, fatal)

  • :message (String)

    The log message

  • :data (Hash)

    Additional structured data (optional)

  • :sessionId (String)

    Session identifier for grouping related logs (optional)

  • :sentAt (String)

    ISO8601 date - will be automatically set if not provided



23
24
25
# File 'lib/boringmetrics/log_methods.rb', line 23

def send(log)
  @client.add_log(log)
end

#send_batch(logs) ⇒ void

This method returns an undefined value.

Send multiple log events in a batch

Parameters:

  • logs (Array<Hash>)

    Array of log events to send



31
32
33
# File 'lib/boringmetrics/log_methods.rb', line 31

def send_batch(logs)
  logs.each { |log| send(log) }
end