Module: StdLogger
- Defined in:
- lib/stdlogger.rb,
lib/stdlogger/error.rb,
lib/stdlogger/version.rb,
lib/stdlogger/multi_io.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.3.0"
Class Method Summary collapse
-
.create(logdev = nil, options = {}) ⇒ Logger
When no target device available, this method raises StdLogger::Error without ‘:allow_nodev’ option.
Class Method Details
.create(logdev = nil, options = {}) ⇒ Logger
When no target device available, this method raises StdLogger::Error without ‘:allow_nodev’ option.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/stdlogger.rb', line 22 def self.create logdev=nil, ={} stdout = [:stdout] || true stderr = [:stderr] || false shift_age = [:shift_age] || 0 shift_size = [:shift_size] || 1048576 targets = [] if logdev if logdev.class == String targets << File.open(logdev, 'a') else targets << logdev end end targets << $stdout if (stdout and $stdout.tty?) targets << $stderr if (stderr and $stderr.tty?) if targets.empty? and ![:allow_nodev] raise Error, "No output device found!" end multi_dev = MultiIO.new targets Logger.new multi_dev, shift_age, shift_size end |