Class: ManageIQ::Loggers::File

Inherits:
Base
  • Object
show all
Defined in:
lib/manageiq/loggers/file.rb

Constant Summary

Constants inherited from Base

Base::MAX_LOG_LINE_LENGTH

Instance Attribute Summary

Attributes inherited from Base

#logdev

Instance Method Summary collapse

Methods inherited from Base

#initialize, #level, #log_backtrace, log_hashes, #log_hashes, log_hashes_filter, #log_hashes_filter, log_hashes_filter=, #log_hashes_filter=, #silence, wrap, #wrap

Constructor Details

This class inherits a constructor from ManageIQ::Loggers::Base

Instance Method Details

#contents(line_count = 1_000, buffer_size = 8_192) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/manageiq/loggers/file.rb', line 4

def contents(line_count = 1_000, buffer_size = 8_192)
  return [] unless logdev&.filename && ::File.exist?(logdev.filename)

  tail(line_count, buffer_size)
    .select { |line| line&.unpack("U*") rescue nil }
    .map { |line| line.force_encoding("utf-8") }
end