Sha256: aa3914e03dca5ac629eeec818dc219755283142adff334ad788b70505848bde0

Contents?: true

Size: 639 Bytes

Versions: 1

Compression:

Stored size: 639 Bytes

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'djb/daemontools/multilog/log'
module Djb
  module Daemontools
    module Multilog
      class Logs < Array

        def load(file,lines = nil)
          @file = file
          open(file) do |f|
            n = 0
            while line = f.gets
              n += 1
              self << Log.new(line,service)
              break if lines and n >= lines
            end
          end
          self
        end

        def service
          $1 if /\/([^\/]+)\/log\/main\/current/ =~ @file
        end

        def to_s
          join("\n",self)
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multilog-collector-0.3.0 lib/djb/daemontools/multilog/logs.rb