Sha256: 5a02902398020b353ec3a52c0dcefb0303b9d8a836b2d41d5f13e720017a60ad

Contents?: true

Size: 788 Bytes

Versions: 13

Compression:

Stored size: 788 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|
  object = get_object(line.chomp!)
  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.14 bin/ix-log
ix-cli-0.0.13 bin/ix-log
ix-cli-0.0.12 bin/ix-log
ix-cli-0.0.11 bin/ix-log
ix-cli-0.0.10 bin/ix-log
ix-cli-0.0.9 bin/ix-log
ix-cli-0.0.7 bin/ix-log
ix-cli-0.0.6 bin/ix-log
ix-cli-0.0.5 bin/ix-log
ix-cli-0.0.4 bin/ix-log
ix-cli-0.0.3 bin/ix-log
ix-cli-0.0.2 bin/ix-log
ix-cli-0.0.1 bin/ix-log