Class: Dply::CustomLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/dply/custom_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Parameters:

  • value

    the value to set the attribute enable_markers to.



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

Parameters:

  • value

    the value to set the attribute remote_mode to.



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

Parameters:

  • value

    the value to set the attribute trace_mode to.



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 format_message(severity, timestamp, 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