Class: Http_Error_Log_Helper
- Inherits:
-
Object
- Object
- Http_Error_Log_Helper
- Defined in:
- lib/Http_Error_Log.rb
Overview
def Http_Error_Log
Class Method Summary collapse
- .to_kv(str) ⇒ Object
-
.to_time(str) ⇒ Object
Example input: “2012/05/08 04:08:19 [error] 11563#0: *183 connect() failed (111: Connection refused) while connecting to upstream”.
Class Method Details
.to_kv(str) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/Http_Error_Log.rb', line 45 def to_kv str pieces = str.split(':') k = pieces.shift v = pieces.join(':') [ k.strip.to_sym, v.strip ] end |
.to_time(str) ⇒ Object
Example input: “2012/05/08 04:08:19 [error] 11563#0: *183 connect() failed (111: Connection refused) while connecting to upstream”
Output:
- Time, ‘[error
-
1156#0’, rest ]
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/Http_Error_Log.rb', line 59 def to_time str pieces = str.split date = pieces.shift time = pieces.shift raw_err = pieces.join(' ').split(':') err = raw_err.shift msg = raw_err.join(':') [ Time.parse("#{date} #{time}" ), err.strip, msg.strip] end |