Module: LoggerModule
- Included in:
- Logger, LoggerError
- Defined in:
- lib/logger.rb
Instance Method Summary collapse
- #initialize ⇒ Object
- #save(path) ⇒ Object
- #silent ⇒ Object
- #silent=(enable) ⇒ Object
- #strip_color(str) ⇒ Object
- #write_console(str, target) ⇒ Object
Instance Method Details
#initialize ⇒ Object
19 20 21 22 |
# File 'lib/logger.rb', line 19 def initialize super @is_silent = false end |
#save(path) ⇒ Object
40 41 42 |
# File 'lib/logger.rb', line 40 def save(path) File.write(path, string) end |
#silent ⇒ Object
28 29 30 |
# File 'lib/logger.rb', line 28 def silent @is_silent end |
#silent=(enable) ⇒ Object
24 25 26 |
# File 'lib/logger.rb', line 24 def silent=(enable) @is_silent = !!enable end |
#strip_color(str) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/logger.rb', line 32 def strip_color(str) if $disable_color str else str.gsub(/(?:\e\[\d*[a-zA-Z])+/, "") end end |
#write_console(str, target) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/logger.rb', line 44 def write_console(str, target) unless @is_silent if $disable_color target.write(str) else write_color(str, target) end end end |