Module: JsonLogging::Helpers

Defined in:
lib/json_logging/helpers.rb

Class Method Summary collapse

Class Method Details

.normalize_timestamp(timestamp) ⇒ Object

Normalize timestamp to ISO8601 with microseconds



6
7
8
# File 'lib/json_logging/helpers.rb', line 6

def normalize_timestamp(timestamp)
  (timestamp || Time.now).utc.iso8601(6)
end

.safe_string(obj) ⇒ Object

Safely convert object to string, never raises



11
12
13
14
15
# File 'lib/json_logging/helpers.rb', line 11

def safe_string(obj)
  obj.to_s
rescue
  "<unprintable>"
end