Sha256: 3133fd718e2adde35d41eab6f572fdb51513f1528da9cd4b89ec37c15f0db86d

Contents?: true

Size: 826 Bytes

Versions: 13

Compression:

Stored size: 826 Bytes

Contents

#!/usr/bin/env ruby

require 'json'
require 'securerandom'

$stdout.sync = true
$stdin.sync = true

TRACE_ID = ENV['TRACE_ID'] || SecureRandom.hex

def get_object(message)
  object = {}
  object[:trace_id] = TRACE_ID
  object[:token_id] = SecureRandom.hex
  object[:message] = message
  object[:timestamp] = Time.now.to_f
  object
end

def print_marker(marker)
  object = get_object('ix log initiation marker')
  puts JSON.dump(object)
end

print_markers = true

if ARGV[0]
  print_markers = false
end

if print_markers
  object = get_object('ix log initiation marker')
  puts JSON.dump(object)
end

STDIN.each_line do |line|
  text = line.chomp!.force_encoding("utf-8")
  object = get_object(text)
  puts JSON.dump(object)
end

if print_markers
  object = get_object('ix log termination marker')
  puts JSON.dump(object)
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ix-cli-0.0.27 bin/ix-log
ix-cli-0.0.26 bin/ix-log
ix-cli-0.0.25 bin/ix-log
ix-cli-0.0.24 bin/ix-log
ix-cli-0.0.23 bin/ix-log
ix-cli-0.0.22 bin/ix-log
ix-cli-0.0.21 bin/ix-log
ix-cli-0.0.20 bin/ix-log
ix-cli-0.0.19 bin/ix-log
ix-cli-0.0.18 bin/ix-log
ix-cli-0.0.17 bin/ix-log
ix-cli-0.0.16 bin/ix-log
ix-cli-0.0.15 bin/ix-log