Module: Pione::Log::MessageLog
- Included in:
- Pione, Agent::JobManager, Agent::TupleSpaceClient, RuleEngine::BasicHandler
- Defined in:
- lib/pione/log/message-log.rb
Overview
MessageLog is a set of utility methods for sending messages to user.
Message Mode collapse
- @@debug_mode =
This classvariable is part of a private API. You should avoid using this classvariable if possible, as it may be removed or be changed in the future.
false
- @@quiet_mode =
This classvariable is part of a private API. You should avoid using this classvariable if possible, as it may be removed or be changed in the future.
false
Constant Summary collapse
- MESSAGE_QUEUE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Queue.new
Message Mode collapse
-
.debug_mode { ... } ⇒ void
Evaluate the block in debug mode.
-
.debug_mode=(mode) ⇒ void
Set debug mode.
-
.debug_mode? ⇒ bool
Return true if the system is debug mode.
-
.quiet_mode { ... } ⇒ void
Evaluate the block in quiet mode.
-
.quiet_mode=(mode) ⇒ void
Set quiet mode.
-
.quiet_mode? ⇒ bool
Return true if the system is quiet mode.
Message Senders collapse
-
.message(type, head, color, msg, level = 0) ⇒ Object
private
Print the message with the color.
-
#debug_message(msg, level = 0, head = "debug") ⇒ void
Send the debug message.
-
#debug_message_begin(msg) ⇒ void
Send the debug message to notify that something begins.
-
#debug_message_end(msg) ⇒ void
Send the debug message to notify that something ends.
-
#show(msg) ⇒ Object
private
Show the message.
-
#user_message(msg, level = 0, head = "info", color = :green) ⇒ void
Send the user message.
-
#user_message_begin(msg, level = 0) ⇒ void
Send the user message to notify that something begins.
-
#user_message_end(msg, level = 0) ⇒ void
Send the debug message to notify that something ends.
Class Method Details
.debug_mode { ... } ⇒ void
This method returns an undefined value.
Evaluate the block in debug mode.
28 29 30 31 32 33 |
# File 'lib/pione/log/message-log.rb', line 28 def debug_mode orig = @@debug_mode @@debug_mode = true yield @@debug_mode = orig end |
.debug_mode=(mode) ⇒ void
This method returns an undefined value.
Set debug mode.
41 42 43 |
# File 'lib/pione/log/message-log.rb', line 41 def debug_mode=(mode) @@debug_mode = mode end |
.debug_mode? ⇒ bool
Return true if the system is debug mode.
49 50 51 |
# File 'lib/pione/log/message-log.rb', line 49 def debug_mode? @@debug_mode end |
.message(type, head, color, msg, level = 0) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Print the message with the color.
176 177 178 179 180 |
# File 'lib/pione/log/message-log.rb', line 176 def (type, head, color, msg, level=0) write(TupleSpace::MessageTuple.new(type: type, head: head, color: color, contents: msg, level: level)) rescue NoMethodError MESSAGE_QUEUE.push "%s%s %s" % [" "*level, ("%5s" % head).color(color), msg] end |
.quiet_mode { ... } ⇒ void
This method returns an undefined value.
Evaluate the block in quiet mode.
59 60 61 62 63 64 |
# File 'lib/pione/log/message-log.rb', line 59 def quiet_mode orig = @@quiet_mode @@quiet_mode = true yield @@quiet_mode = orig end |
.quiet_mode=(mode) ⇒ void
This method returns an undefined value.
Set quiet mode.
72 73 74 |
# File 'lib/pione/log/message-log.rb', line 72 def quiet_mode=(mode) @@quiet_mode = mode end |
.quiet_mode? ⇒ bool
Return true if the system is quiet mode.
80 81 82 |
# File 'lib/pione/log/message-log.rb', line 80 def quiet_mode? @@quiet_mode end |
Instance Method Details
#debug_message(msg, level = 0, head = "debug") ⇒ void
This method returns an undefined value.
Send the debug message.
96 97 98 99 100 |
# File 'lib/pione/log/message-log.rb', line 96 def (msg, level=0, head="debug") if debug_mode? and not(quiet_mode?) (:debug, head, :magenta, " "*level + msg) end end |
#debug_message_begin(msg) ⇒ void
This method returns an undefined value.
Send the debug message to notify that something begins.
107 108 109 |
# File 'lib/pione/log/message-log.rb', line 107 def (msg) (msg, 0, ">>>") end |
#debug_message_end(msg) ⇒ void
This method returns an undefined value.
Send the debug message to notify that something ends.
116 117 118 |
# File 'lib/pione/log/message-log.rb', line 116 def (msg) (msg, 0, "<<<") end |
#show(msg) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Use this for debugging only.
Show the message.
162 163 164 |
# File 'lib/pione/log/message-log.rb', line 162 def show(msg) (:debug, "show", :red, msg) end |
#user_message(msg, level = 0, head = "info", color = :green) ⇒ void
This method returns an undefined value.
Send the user message.
129 130 131 132 133 |
# File 'lib/pione/log/message-log.rb', line 129 def (msg, level=0, head="info", color=:green) if not(quiet_mode?) (:info, head, color, msg, level) end end |
#user_message_begin(msg, level = 0) ⇒ void
This method returns an undefined value.
Send the user message to notify that something begins.
140 141 142 |
# File 'lib/pione/log/message-log.rb', line 140 def (msg, level=0) (msg, level, "-->") end |
#user_message_end(msg, level = 0) ⇒ void
This method returns an undefined value.
Send the debug message to notify that something ends.
149 150 151 |
# File 'lib/pione/log/message-log.rb', line 149 def (msg, level=0) (msg, level, "<--") end |