No commit activity in last 3 years
No release in over 3 years
Ruby monitoring and transform logfiles daemon.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.1.3
 Project Readme

Logfile Transfer

Ruby monitoring and transform logfiles daemon.

Installation

gem install logfile_transfer
# you may need to run:
sudo gem install logfile_transfer

Examples

Edit example.rb

require 'logfile_transfer'

class Test < LogfileTransfer::Handler

  def init
    @test_log_file = File.new '/tmp/test.log', 'a'
    @test_log_file.sync = true
  end

  def handle log_path, log_fn, line, line_count, pattern
    @test_log_file.puts "#{log_path}, #{log_fn}, #{line_count}, #{pattern}"
  end

end

# The daemon binding on port 2000, make it different in other daemon
LogfileTransfer.run ARGV, 2000, File.expand_path(File.dirname(__FILE__))

Edit config.yaml

---
- !ruby/object:LogfileTransfer::FileMonitorObj
  absolute_path: /data/webroot/log
  dir_disallow: []
  file_disallow:
  - .*
  file_allow:
  - \.log\.
  patterns:
  - - .*
    - - !ruby/object:Test {}

Run

# as root user, run:
Ruby example.rb start
# you may need to run:
sudo Ruby example.rb start

Status

Ruby example.rb status

Stop

Ruby example.rb stop

Multiple folders, different log and more Handler in a daemon process

Edit example.rb

require 'logfile_transfer'

class Test < LogfileTransfer::Handler

  def init
    @test_log_file = File.new '/tmp/test.log', 'a'
    @test_log_file.sync = true
  end

  def handle log_path, log_fn, line, line_count, pattern
    @test_log_file.puts "#{log_path}, #{log_fn}, #{line_count}, #{pattern}"
  end

end

class Test1 < LogfileTransfer::Handler

  def init
    @test1_log_file = File.new '/tmp/test1.log', 'a'
    @test1_log_file.sync = true
  end

  def handle log_path, log_fn, line, line_count, pattern
    @test1_log_file.puts line
  end

end

LogfileTransfer.run ARGV, 2000, File.expand_path(File.dirname(__FILE__))

Edit config.yaml

---
- !ruby/object:LogfileTransfer::FileMonitorObj
  absolute_path: /data/webroot/log
  dir_disallow: []
  file_disallow:
  - .*
  file_allow:
  - \.log\.
  patterns:
  - - gamestart
    - - !ruby/object:Test {}
      - !ruby/object:Test1 {}
  - - gamestop
    - - !ruby/object:Test {}
      - !ruby/object:Test1 {}
- !ruby/object:LogfileTransfer::FileMonitorObj
  absolute_path: /data/webroot/tlog
  dir_disallow: []
  file_disallow:
  - .*
  file_allow:
  - \.log\.
  patterns:
  - - gamestart
    - - !ruby/object:Test {}
      - !ruby/object:Test1 {}