Class: ModSpox::LogWriter
- Inherits:
-
Object
- Object
- ModSpox::LogWriter
- Defined in:
- lib/mod_spox/Logger.rb
Instance Attribute Summary collapse
-
#fd ⇒ Object
readonly
Returns the value of attribute fd.
Instance Method Summary collapse
-
#initialize(fd) ⇒ LogWriter
constructor
A new instance of LogWriter.
- #kill ⇒ Object
- #log(message) ⇒ Object
- #processor ⇒ Object
Constructor Details
#initialize(fd) ⇒ LogWriter
Returns a new instance of LogWriter.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mod_spox/Logger.rb', line 50 def initialize(fd) @fd = fd @kill = false @queue = Queue.new @thread = Thread.new do until(@kill) processor end end end |
Instance Attribute Details
#fd ⇒ Object (readonly)
Returns the value of attribute fd.
48 49 50 |
# File 'lib/mod_spox/Logger.rb', line 48 def fd @fd end |
Instance Method Details
#kill ⇒ Object
61 62 63 64 |
# File 'lib/mod_spox/Logger.rb', line 61 def kill @kill = true @queue << "Logger has been told to shut down" end |
#log(message) ⇒ Object
66 67 68 |
# File 'lib/mod_spox/Logger.rb', line 66 def log() @queue << end |
#processor ⇒ Object
70 71 72 73 |
# File 'lib/mod_spox/Logger.rb', line 70 def processor = @queue.pop @fd.puts("LOGGER [#{Time.now}]: #{message}") end |