Skip to content

Commit

Permalink
Add debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kaosf committed Jun 4, 2024
1 parent 819a7bd commit a83942b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@

require "logger"
LOGGER = Logger.new $stdout
LOGGER.level =
case ENV.fetch("RUBY_LOG_LEVEL", "info")
when "unknown" then Logger::UNKNOWN
when "fatal" then Logger::FATAL
when "error" then Logger::ERROR
when "warn" then Logger::WARN
when "info" then Logger::INFO
when "debug" then Logger::DEBUG
else Logger::INFO
end

require "activerecord-import"

Expand Down Expand Up @@ -85,10 +95,15 @@ def build_nostr_event(line)
def fetch_events(since)
nostr_events = []
begin
LOGGER.debug("Timeout seconds: #{NOSDUMP_TIMEOUT_SECONDS}")
Timeout.timeout(NOSDUMP_TIMEOUT_SECONDS) do
LOGGER.debug("Before Open3.popen3")
Open3.popen3("nosdump", "--since", since, "--authors", *AUTHORS, *RELAYS) do |stdin, stdout, _, _|
LOGGER.debug("In Open3.popen3 block; Before stdin.close")
stdin.close
LOGGER.debug("In Open3.popen3 block; Before stdout.each_line")
stdout.each_line do |line|
LOGGER.debug("In Open3.popen3 block; In stdout.each_line block; loop of line: #{line[0...50]}")
nostr_events << build_nostr_event(line.chomp)
rescue StandardError => e
LOGGER.error e
Expand Down

0 comments on commit a83942b

Please sign in to comment.