Class: SyslogGenerator::Logger
- Inherits:
-
Object
- Object
- SyslogGenerator::Logger
- Defined in:
- lib/syslog_generator.rb
Overview
Implementation of a log formatter/sender
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options) ⇒ Logger
constructor
A new instance of Logger.
- #send(text) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(options) ⇒ Logger
Returns a new instance of Logger.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/syslog_generator.rb', line 44 def initialize() self. = # TODO: Won't work on systems that don't have `hostname`? @formatter = SyslogProtocol::Logger.new( `hostname`.strip, [:name], [:facility] ) @socket = initialize_socket() end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
10 11 12 |
# File 'lib/syslog_generator.rb', line 10 def @options end |
Instance Method Details
#send(text) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/syslog_generator.rb', line 55 def send(text) if [:test] puts(gen_payload(text)) else @socket.send(gen_payload(text), 0, [:server], [:port]) end end |
#start ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/syslog_generator.rb', line 63 def start if [:count] != -1 [:count].times { send(gen_words) } else loop { send(gen_words) } end end |