Add plain text and coloured logging to the Client

Logs websocket events (connect, message, error and close events)
This commit is contained in:
Wilson Silva
2024-04-13 13:55:36 +01:00
parent a0cf41bfb4
commit 90ab1a6149
19 changed files with 742 additions and 10 deletions

View File

@@ -10,6 +10,7 @@ module Nostr
private
attr_reader logger: Logger
attr_reader subscriptions: Hash[String, Subscription]
attr_reader parent_to_child_channel: EventMachine::Channel
attr_reader child_to_parent_channel: EventMachine::Channel

View File

@@ -0,0 +1,6 @@
module Nostr
class Client
class ColorLogger < Logger
end
end
end

View File

@@ -0,0 +1,12 @@
module Nostr
class Client
class Logger
def attach_to: (Client client) -> void
def on_connect: (Relay relay) -> void
def on_message: (String message) -> void
def on_send: (String message) -> void
def on_error: (String message) -> void
def on_close: (String code, String reason) -> void
end
end
end

View File

@@ -0,0 +1,6 @@
module Nostr
class Client
class PlainLogger < Logger
end
end
end