Class: L2met::Syslog
- Inherits:
-
Object
- Object
- L2met::Syslog
- Defined in:
- lib/l2met/syslog.rb,
lib/l2met/syslog/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#logger ⇒ Object
Returns the value of attribute logger.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Syslog
constructor
A new instance of Syslog.
- #log(params) ⇒ Object
- #log_data ⇒ Object
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Syslog
Returns a new instance of Syslog.
13 14 15 16 |
# File 'lib/l2met/syslog.rb', line 13 def initialize( = {}) @logger = [:logger] || default_logger @interval = [:interval] || 60 end |
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval.
7 8 9 |
# File 'lib/l2met/syslog.rb', line 7 def interval @interval end |
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/l2met/syslog.rb', line 6 def logger @logger end |
Class Method Details
.run(options = {}) ⇒ Object
9 10 11 |
# File 'lib/l2met/syslog.rb', line 9 def self.run( = {}) new().run end |
Instance Method Details
#log(params) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/l2met/syslog.rb', line 35 def log(params) if @logger = params.map {|p| p.join('=') }.join(' ') @logger.info() end end |
#log_data ⇒ Object
31 32 33 |
# File 'lib/l2met/syslog.rb', line 31 def log_data raise "This method must be implemented" end |
#run ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/l2met/syslog.rb', line 18 def run @thread = Thread.new do loop do sleep @interval log_data end end end |
#stop ⇒ Object
27 28 29 |
# File 'lib/l2met/syslog.rb', line 27 def stop @thread.exit if @thread end |