Class: ObservationCompiler::LogLine
- Inherits:
-
Object
- Object
- ObservationCompiler::LogLine
- Defined in:
- lib/logbox/observation_compiler.rb
Constant Summary collapse
- TIMESTAMP_MATCHER =
/(\d+)\/(\w+)\/(\d+):(\d+):(\d+):(\d+)\s([-+]?\d{2})/
Instance Method Summary collapse
- #date ⇒ Object
-
#initialize(line) ⇒ LogLine
constructor
A new instance of LogLine.
- #normalize ⇒ Object
- #timestamp ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(line) ⇒ LogLine
Returns a new instance of LogLine.
234 235 236 |
# File 'lib/logbox/observation_compiler.rb', line 234 def initialize(line) @line = Logbox::StringEncoder.iconv(line) end |
Instance Method Details
#date ⇒ Object
263 264 265 |
# File 'lib/logbox/observation_compiler.rb', line 263 def date .send :to_date end |
#normalize ⇒ Object
245 246 247 248 249 250 |
# File 'lib/logbox/observation_compiler.rb', line 245 def normalize normalize_s3_format normalize_apache_format @line end |
#timestamp ⇒ Object
254 255 256 257 258 259 260 261 |
# File 'lib/logbox/observation_compiler.rb', line 254 def unless @timestamp match = @line.match(TIMESTAMP_MATCHER) @timestamp = Time.utc(match[3], match[2], match[1], match[4], match[5], match[6]) @timestamp -= match[7].to_i * 3600 # Correct the zone. Works only on whole hours timezones. end @timestamp end |
#to_s ⇒ Object
267 268 269 |
# File 'lib/logbox/observation_compiler.rb', line 267 def to_s @line end |
#valid? ⇒ Boolean
238 239 240 241 242 243 |
# File 'lib/logbox/observation_compiler.rb', line 238 def valid? normalize true rescue false end |