Module: Conveyor::Output
- Included in:
- Belt, Foreman, Worker
- Defined in:
- lib/conveyor/output.rb,
lib/conveyor/output/email.rb,
lib/conveyor/output/channel.rb,
lib/conveyor/output/console.rb,
lib/conveyor/output/logfile.rb
Defined Under Namespace
Classes: Channel, Console, Email, Logfile
Constant Summary
collapse
- MSGLVLS =
{
:debug => 1,
:info => 10,
:warning => 20,
:error => 30,
:announce => 40
}
Instance Method Summary
collapse
Instance Method Details
#announce(*msg) ⇒ Object
61
62
63
|
# File 'lib/conveyor/output.rb', line 61
def announce(*msg)
output(:announce, *msg)
end
|
#debug(*msg) ⇒ Object
57
58
59
|
# File 'lib/conveyor/output.rb', line 57
def debug(*msg)
output(:debug, *msg)
end
|
#error(*msg) ⇒ Object
53
54
55
|
# File 'lib/conveyor/output.rb', line 53
def error(*msg)
output(:error, *msg)
end
|
#info(*msg) ⇒ Object
45
46
47
|
# File 'lib/conveyor/output.rb', line 45
def info(*msg)
output(:info, *msg)
end
|
#logfile ⇒ Object
Overrite this method to control logfile used
32
33
34
|
# File 'lib/conveyor/output.rb', line 32
def logfile
nil
end
|
#loglvl(lvl) ⇒ Object
27
28
29
|
# File 'lib/conveyor/output.rb', line 27
def loglvl(lvl)
@loglvl = MSGLVLS[lvl.to_sym] || MSGLVLS[:debug]
end
|
#name ⇒ Object
Override this method to control name used
37
38
39
|
# File 'lib/conveyor/output.rb', line 37
def name
nil
end
|
#notify(*emails) ⇒ Object
77
78
79
|
# File 'lib/conveyor/output.rb', line 77
def notify(*emails)
Conveyor::Foreman.instance.notify_list << emails
end
|
#output(msgtype, *msg) ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/conveyor/output.rb', line 65
def output(msgtype, *msg)
return false unless should_log?(msgtype)
Console.write(msgtype, *msg)
Logfile.write(logfile, name, msgtype, *msg)
Email.write(msgtype, *msg)
Channel.instance.write(name, msgtype, *msg)
end
|
#say(*msg) ⇒ Object
41
42
43
|
# File 'lib/conveyor/output.rb', line 41
def say(*msg)
output(:info, *msg)
end
|
#send_notifications ⇒ Object
73
74
75
|
# File 'lib/conveyor/output.rb', line 73
def send_notifications
Email.mail
end
|
#should_log?(lvl, maxlvl = nil) ⇒ Boolean
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/conveyor/output.rb', line 16
def should_log?(lvl, maxlvl = nil)
if maxlvl.nil? && @loglvl.nil?
loglvl :debug
should_log? lvl
elsif maxlvl.nil?
MSGLVLS[lvl.to_sym] >= @loglvl
else
MSGLVLS[lvl.to_sym] >= MSGLVLS[maxlvl.to_sym]
end
end
|
#warning(*msg) ⇒ Object
49
50
51
|
# File 'lib/conveyor/output.rb', line 49
def warning(*msg)
output(:warning, *msg)
end
|