Class: Dply::CustomLogger
- Inherits:
-
Logger
- Object
- Logger
- Dply::CustomLogger
- Defined in:
- lib/dply/custom_logger.rb
Instance Attribute Summary collapse
-
#enable_markers ⇒ Object
writeonly
Sets the attribute enable_markers.
-
#remote_mode ⇒ Object
writeonly
Sets the attribute remote_mode.
-
#trace_mode ⇒ Object
writeonly
Sets the attribute trace_mode.
Instance Method Summary collapse
- #arrow(msg) ⇒ Object
- #bullet(msg) ⇒ Object
- #command(command, mode:) ⇒ Object
- #format_message(severity, timestamp, progname, msg) ⇒ Object
-
#initialize(file) ⇒ CustomLogger
constructor
A new instance of CustomLogger.
- #marker(msg) ⇒ Object
- #remote(msg) ⇒ Object
- #silence! ⇒ Object
- #trace(msg) ⇒ Object
Constructor Details
#initialize(file) ⇒ CustomLogger
Returns a new instance of CustomLogger.
9 10 11 12 13 |
# File 'lib/dply/custom_logger.rb', line 9 def initialize(file) super(file) @level = ::Logger::INFO # @trace_mode = false end |
Instance Attribute Details
#enable_markers=(value) ⇒ Object (writeonly)
Sets the attribute enable_markers
7 8 9 |
# File 'lib/dply/custom_logger.rb', line 7 def enable_markers=(value) @enable_markers = value end |
#remote_mode=(value) ⇒ Object (writeonly)
Sets the attribute remote_mode
7 8 9 |
# File 'lib/dply/custom_logger.rb', line 7 def remote_mode=(value) @remote_mode = value end |
#trace_mode=(value) ⇒ Object (writeonly)
Sets the attribute trace_mode
7 8 9 |
# File 'lib/dply/custom_logger.rb', line 7 def trace_mode=(value) @trace_mode = value end |
Instance Method Details
#arrow(msg) ⇒ Object
39 40 41 |
# File 'lib/dply/custom_logger.rb', line 39 def arrow(msg) info "#{"\u2023".green.bold} #{msg}" end |
#bullet(msg) ⇒ Object
43 44 45 |
# File 'lib/dply/custom_logger.rb', line 43 def bullet(msg) info "#{"\u2219".bold.blue} #{msg}" end |
#command(command, mode:) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dply/custom_logger.rb', line 28 def command(command, mode:) case mode when :arrow arrow command when :bullet bullet command else debug command end end |
#format_message(severity, timestamp, progname, msg) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dply/custom_logger.rb', line 15 def (severity, , progname, msg) case severity when "INFO" "#{msg}\n" when "ERROR" "#{severity.bold.red} #{msg}\n" when "WARN" "#{severity.downcase.bold.yellow} #{msg}\n" else "#{severity[0].bold.blue} #{msg}\n" end end |
#marker(msg) ⇒ Object
57 58 59 60 |
# File 'lib/dply/custom_logger.rb', line 57 def marker(msg) return if not @enable_markers info "dply_marker:#{msg}" end |
#remote(msg) ⇒ Object
52 53 54 55 |
# File 'lib/dply/custom_logger.rb', line 52 def remote(msg) return if not @remote_mode info %{dply_msg|#{msg}} end |
#silence! ⇒ Object
62 63 64 |
# File 'lib/dply/custom_logger.rb', line 62 def silence! @logdev = nil end |
#trace(msg) ⇒ Object
47 48 49 50 |
# File 'lib/dply/custom_logger.rb', line 47 def trace(msg) return if not @trace_mode info %(#{"T".bold.blue} #{msg}\n) end |