Class: Conveyor::Output::Logfile
- Inherits:
-
Object
- Object
- Conveyor::Output::Logfile
- Defined in:
- lib/conveyor/output/logfile.rb
Class Method Summary collapse
Class Method Details
.output(logfile, msg = nil, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/conveyor/output/logfile.rb', line 23 def output(logfile, msg = nil, &block) FileUtils.mkdir_p(File.dirname(logfile)) fp = File.open(logfile, 'a') if block_given? yield fp elsif !msg.nil? fp << msg + "\n" end fp.close end |
.write(logfile, name, msgtype, *msg) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/conveyor/output/logfile.rb', line 5 def write(logfile, name, msgtype, *msg) return false if logfile.nil? = msg. format = '[%s] [%s::%s] %s' if msg.class == Array msg.each do |m| output logfile, sprintf(format, Time.now, name, msgtype, m) end else output logfile, sprintf(format, Time.now, name, msgtype, msg) end end |