Class: Bj::Logger
Defined Under Namespace
Modules: OnOff
Class Method Summary collapse
Instance Method Summary collapse
- #device ⇒ Object
- #format_message(severity, datetime, progname, msg) ⇒ Object
- #off ⇒ Object
- #off! ⇒ Object
- #on ⇒ Object
- #on! ⇒ Object
- #tty? ⇒ Boolean
- #turn(which) ⇒ Object
Class Method Details
.new(*a, &b) ⇒ Object
3 4 5 |
# File 'lib/bj/logger.rb', line 3 def self.new *a, &b super(*a, &b).instance_eval{ @default_formatter = @formatter = Formatter.new; self } end |
.off(*a, &b) ⇒ Object
46 47 48 |
# File 'lib/bj/logger.rb', line 46 def self.off *a, &b new(*a, &b).instance_eval{ turn :off; self } end |
.on(*a, &b) ⇒ Object
38 39 40 |
# File 'lib/bj/logger.rb', line 38 def self.on *a, &b new(*a, &b).instance_eval{ turn :on; self } end |
Instance Method Details
#device ⇒ Object
10 11 12 |
# File 'lib/bj/logger.rb', line 10 def device @logdev.instance_eval{ @dev } end |
#format_message(severity, datetime, progname, msg) ⇒ Object
6 7 8 |
# File 'lib/bj/logger.rb', line 6 def (severity, datetime, progname, msg) (@formatter || @default_formatter).call(severity, datetime, progname, msg) end |
#off ⇒ Object
42 43 44 |
# File 'lib/bj/logger.rb', line 42 def off turn :off end |
#off! ⇒ Object
45 46 47 |
# File 'lib/bj/logger.rb', line 45 def off turn :off end |
#on ⇒ Object
34 35 36 |
# File 'lib/bj/logger.rb', line 34 def on turn :on end |
#on! ⇒ Object
37 38 39 |
# File 'lib/bj/logger.rb', line 37 def on turn :on end |
#tty? ⇒ Boolean
14 15 16 |
# File 'lib/bj/logger.rb', line 14 def tty? device.respond_to?('tty?') and device.tty? end |