Class: Pione::Log::PioneSystemLogger
- Inherits:
-
BasicLogger
- Object
- Rootage::Logger
- BasicLogger
- Pione::Log::PioneSystemLogger
- Defined in:
- lib/pione/log/system-log.rb
Overview
Log::PioneSystemLogger
is a PIONE original logger. This generates very
colorful message for identifiability and detailed informations.
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
Instance Method Summary collapse
- #debug(msg, pos = caller(1).first, pid = Process.pid) ⇒ Object
- #error(msg, pos = caller(1).first, pid = Process.pid) ⇒ Object
- #fatal(msg, pos = caller(1).first, pid = Process.pid) ⇒ Object
- #info(msg, pos = caller(1).first, pid = Process.pid) ⇒ Object
-
#initialize(out = nil) ⇒ PioneSystemLogger
constructor
A new instance of PioneSystemLogger.
- #queued? ⇒ Boolean
- #terminate ⇒ Object
- #warn(msg, pos = caller(1).first, pid = Process.pid) ⇒ Object
Methods inherited from Rootage::Logger
Constructor Details
#initialize(out = nil) ⇒ PioneSystemLogger
Returns a new instance of PioneSystemLogger.
52 53 54 55 56 57 58 59 |
# File 'lib/pione/log/system-log.rb', line 52 def initialize(out = nil) super() @queue = Queue.new @thread = make_writer_thread @lock = Mutex.new @out = out end |
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
50 51 52 |
# File 'lib/pione/log/system-log.rb', line 50 def level @level end |
Instance Method Details
#debug(msg, pos = caller(1).first, pid = Process.pid) ⇒ Object
65 |
# File 'lib/pione/log/system-log.rb', line 65 def debug(msg, pos=caller(1).first, pid=Process.pid); push(:debug, msg, pos, pid); end |
#error(msg, pos = caller(1).first, pid = Process.pid) ⇒ Object
62 |
# File 'lib/pione/log/system-log.rb', line 62 def error(msg, pos=caller(1).first, pid=Process.pid); push(:error, msg, pos, pid); end |
#fatal(msg, pos = caller(1).first, pid = Process.pid) ⇒ Object
61 |
# File 'lib/pione/log/system-log.rb', line 61 def fatal(msg, pos=caller(1).first, pid=Process.pid); push(:fatal, msg, pos, pid); end |
#info(msg, pos = caller(1).first, pid = Process.pid) ⇒ Object
64 |
# File 'lib/pione/log/system-log.rb', line 64 def info (msg, pos=caller(1).first, pid=Process.pid); push(:info , msg, pos, pid); end |
#queued? ⇒ Boolean
86 87 88 |
# File 'lib/pione/log/system-log.rb', line 86 def queued? not(@queue.empty?) end |
#terminate ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/pione/log/system-log.rb', line 67 def terminate timeout(3) do while @thread.alive? if @queue.empty? and not(@lock.locked?) @thread.kill.join break else sleep 0.1 end end end rescue Timeout::Error # don't use logger here because it is dead at this time $stdout.puts("*** system logger has been terminated unsafety, some messages maybe lost ***") ensure # kill writer thread @thread.kill if @thread.alive? end |
#warn(msg, pos = caller(1).first, pid = Process.pid) ⇒ Object
63 |
# File 'lib/pione/log/system-log.rb', line 63 def warn (msg, pos=caller(1).first, pid=Process.pid); push(:warn , msg, pos, pid); end |