Class: SEKOIA::Formatter
- Inherits:
-
Object
- Object
- SEKOIA::Formatter
- Defined in:
- lib/sekoia/formatter.rb
Constant Summary collapse
- SekoiaID =
"SEKOIA@53288"
- Format =
"<%d>1 %s %s %s %s %s %s %s"
Class Method Summary collapse
- .format(priority: 14, timestamp: nil, log: "", hostname: "-", app_name: "-", proc_id: "-", msg_id: "-", intake_key: "") ⇒ Object
- .format_structured_data(intake_key) ⇒ Object
- .format_time(timestamp) ⇒ Object
Class Method Details
.format(priority: 14, timestamp: nil, log: "", hostname: "-", app_name: "-", proc_id: "-", msg_id: "-", intake_key: "") ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sekoia/formatter.rb', line 9 def format( priority: 14, timestamp: nil, log: "", hostname: "-", app_name: "-", proc_id: "-", msg_id: "-", intake_key: "" ) Format % [priority, format_time(), hostname[0..254], app_name[0..47], proc_id[0..127], msg_id[0..31], format_structured_data(intake_key), log] end |
.format_structured_data(intake_key) ⇒ Object
22 23 24 |
# File 'lib/sekoia/formatter.rb', line 22 def format_structured_data(intake_key) %{[#{SekoiaID} intake_key="#{intake_key}"]} end |
.format_time(timestamp) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/sekoia/formatter.rb', line 26 def format_time() return "-" if .nil? return Time.at(.to_r).utc.to_datetime.rfc3339(6) if .is_a?(Fluent::EventTime) DateTime.strptime(.to_s, '%s').rfc3339(6) end |