class BotConsole::LogFile
Constants
- MAX_ARCHIVES
- MAX_BYTES
Public Class Methods
Source
# File lib/bot_console/log_file.rb, line 15 def initialize(path) @path = path.to_s @mutex = Mutex.new FileUtils.mkdir_p(File.dirname(@path)) end
Public Instance Methods
Source
# File lib/bot_console/log_file.rb, line 21 def append(line) text = line.to_s.chomp return if text.empty? @mutex.synchronize do File.open(@path, "a") { |file| file.puts(text) } rotate_if_needed! invalidate_cache! end end
Source
# File lib/bot_console/log_file.rb, line 42 def archive_count @mutex.synchronize do archive_paths.length end end
Source
# File lib/bot_console/log_file.rb, line 38 def line_count read_lines.length end
Source
# File lib/bot_console/log_file.rb, line 32 def read_lines @mutex.synchronize do @cached_lines ||= load_all_lines end end