[Why]
When other people use monitor to get logs,
the logs only output, not return.
It's hard to deal the logs.
[How]
Append result logs to a list.
Signed-off-by: Wu Zhende <wuzhende666(a)163.com>
---
lib/monitor.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/monitor.rb b/lib/monitor.rb
index 2a10b5c1..baf172d3 100755
--- a/lib/monitor.rb
+++ b/lib/monitor.rb
@@ -11,7 +11,7 @@ require 'eventmachine'
require 'json'
class Monitor
- attr_accessor :monitor_url, :query, :overrides, :action, :job
+ attr_accessor :monitor_url, :query, :overrides, :action, :job, :result
def initialize(monitor_url = '', query = {}, action = {})
@monitor_url = monitor_url
@@ -25,6 +25,7 @@ class Monitor
@exit_status_code = 0
@defaults = {}
load_default
+ @result = []
end
def load_default
@@ -122,6 +123,7 @@ class Monitor
ws.on :message do |event|
data = JSON.parse(event.data)
+ @result << data
output(data)
connect(data, ws)
--
2.23.0