Class: Logtide::Breadcrumb
- Inherits:
-
Object
- Object
- Logtide::Breadcrumb
- Defined in:
- lib/logtide/breadcrumb.rb
Overview
A breadcrumb: a small structured event in the trail leading up to an entry (spec 003 section 5).
Constant Summary collapse
- TYPES =
%w[http navigation ui console query error custom].freeze
Instance Method Summary collapse
-
#initialize(type: "custom", category: nil, message: nil, data: nil, level: "info", timestamp: nil) ⇒ Breadcrumb
constructor
A new instance of Breadcrumb.
- #to_h ⇒ Object
Constructor Details
#initialize(type: "custom", category: nil, message: nil, data: nil, level: "info", timestamp: nil) ⇒ Breadcrumb
Returns a new instance of Breadcrumb.
11 12 13 14 15 16 17 18 19 |
# File 'lib/logtide/breadcrumb.rb', line 11 def initialize(type: "custom", category: nil, message: nil, data: nil, level: "info", timestamp: nil) @type = type @category = category @message = @data = data @level = level.to_s @timestamp = || Time.now.utc end |
Instance Method Details
#to_h ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/logtide/breadcrumb.rb', line 21 def to_h result = { "type" => @type, "level" => @level, "timestamp" => @timestamp.utc.strftime("%Y-%m-%dT%H:%M:%S.%LZ") } result["category"] = @category if @category result["message"] = @message if @message result["data"] = @data if @data result end |