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
4 5 6 |
# File 'lib/bj/logger.rb', line 4 def self.new *a, &b super(*a, &b).instance_eval{ @default_formatter = @formatter = Formatter.new; self } end |
.off(*a, &b) ⇒ Object
47 48 49 |
# File 'lib/bj/logger.rb', line 47 def self.off *a, &b new(*a, &b).instance_eval{ turn :off; self } end |
.on(*a, &b) ⇒ Object
39 40 41 |
# File 'lib/bj/logger.rb', line 39 def self.on *a, &b new(*a, &b).instance_eval{ turn :on; self } end |
Instance Method Details
#device ⇒ Object
11 12 13 |
# File 'lib/bj/logger.rb', line 11 def device @logdev.instance_eval{ @dev } end |
#format_message(severity, datetime, progname, msg) ⇒ Object
7 8 9 |
# File 'lib/bj/logger.rb', line 7 def (severity, datetime, progname, msg) (@formatter || @default_formatter).call(severity, datetime, progname, msg) end |
#off ⇒ Object
43 44 45 |
# File 'lib/bj/logger.rb', line 43 def off turn :off end |
#off! ⇒ Object
46 47 48 |
# File 'lib/bj/logger.rb', line 46 def off turn :off end |
#on ⇒ Object
35 36 37 |
# File 'lib/bj/logger.rb', line 35 def on turn :on end |
#on! ⇒ Object
38 39 40 |
# File 'lib/bj/logger.rb', line 38 def on turn :on end |
#tty? ⇒ Boolean
15 16 17 |
# File 'lib/bj/logger.rb', line 15 def tty? device.respond_to?('tty?') and device.tty? end |