From 07bcf9cfc4038e6b5ee0c544819fdc6692cbab2f Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Wed, 15 Apr 2020 13:39:01 +0000 Subject: [PATCH] add initial timestamping and archived message code --- r2s-bwmsgsv2.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/r2s-bwmsgsv2.rb b/r2s-bwmsgsv2.rb index 2a230b2f9139ccb6085f54ca20cf1d5fa55f8761..d0d704fa5f175b22159156b93844df9551689317 100755 --- a/r2s-bwmsgsv2.rb +++ b/r2s-bwmsgsv2.rb @@ -50,7 +50,23 @@ redis = Redis.new(:driver => :hiredis) while true timestamps_plus_json_blob = redis.brpoplpush('incoming_messages-' + ARGV[0], 'pending_messages-' + ARGV[0]) - # TODO: add timestamping here, and MUST include a ./tai call with it + + t = Time.now + tai_timestamp = `./tai`.strip + tai_yyyymmdd = Time.at(tai_timestamp.to_i).strftime('%Y%m%d') + puts "LOG %d.%09d, %s: msg [TODO: ID] sent on %s - incrementing\n" % + [t.to_i, t.nsec, tai_timestamp, tai_yyyymmdd] + + day_msg_count = redis.incr( + "archived_message-#{ARGV[0]}-#{tai_yyyymmdd}-total" + ).then { |total| + + t = Time.now + puts "LOG %d.%09d: total msgs for %s-%s now at %s\n" % + [t.to_i, t.nsec, tai_yyyymmdd, ARGV[0], total] + } + + # TODO: do something with day_msg_count # TODO: print less stuff in here puts "TODO - got some stuff: " + timestamps_plus_json_blob