Class: Nostr::Client::PlainLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/nostr/client/plain_logger.rb

Overview

Logs connection events, messages sent and received, errors, and connection closures.

Instance Method Summary collapse

Methods inherited from Logger

#attach_to

Instance Method Details

#on_close(code, reason) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Logs a closure of connection with a relay

Parameters:

  • code (String)

    The closure code.

  • reason (String)

    The reason for the closure.



64
65
66
# File 'lib/nostr/client/plain_logger.rb', line 64

def on_close(code, reason)
  puts "Connection closed: #{reason} (##{code})"
end

#on_connect(relay) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Logs connection to a relay

Parameters:

  • relay (Nostr::Relay)

    The relay the client connected to.



15
16
17
# File 'lib/nostr/client/plain_logger.rb', line 15

def on_connect(relay)
  puts "Connected to the relay #{relay.name} (#{relay.url})"
end

#on_error(message) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Logs an error message

Parameters:

  • message (String)

    The error message.



51
52
53
# File 'lib/nostr/client/plain_logger.rb', line 51

def on_error(message)
  puts "Error: #{message}"
end

#on_message(message) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Logs a message received from the relay

Parameters:

  • message (String)

    The message received.



27
28
29
# File 'lib/nostr/client/plain_logger.rb', line 27

def on_message(message)
  puts "◄- #{message}"
end

#on_send(message) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Logs a message sent to the relay

Parameters:

  • message (String)

    The message sent.



39
40
41
# File 'lib/nostr/client/plain_logger.rb', line 39

def on_send(message)
  puts "-► #{message}"
end