Class: Logsly::ColorsData
- Inherits:
-
Object
- Object
- Logsly::ColorsData
- Defined in:
- lib/logsly/colors.rb
Instance Method Summary collapse
-
#date(value = nil) ⇒ Object
- %d
-
datestamp.
-
#debug(value = nil) ⇒ Object
color for the level text only.
-
#debug_line(value = nil) ⇒ Object
color for the entire log message based on the value of the log level.
- #error(value = nil) ⇒ Object
- #error_line(value = nil) ⇒ Object
- #fatal(value = nil) ⇒ Object
- #fatal_line(value = nil) ⇒ Object
-
#file(value = nil) ⇒ Object
- %F
-
filename where the logging request was issued.
- #info(value = nil) ⇒ Object
- #info_line(value = nil) ⇒ Object
-
#initialize(*args, &build) ⇒ ColorsData
constructor
A new instance of ColorsData.
-
#line(value = nil) ⇒ Object
- %L
-
line number where the logging request was issued.
-
#logger(value = nil) ⇒ Object
- %c
-
name of the logger that generate the log event.
-
#message(value = nil) ⇒ Object
- %m
-
the user supplied log message.
-
#method_name(value = nil) ⇒ Object
- %M
-
method name where the logging request was issued.
-
#pid(value = nil) ⇒ Object
- %p
-
PID of the current process.
-
#thread(value = nil) ⇒ Object
- %T
-
the name of the thread Thread.current.
-
#thread_id(value = nil) ⇒ Object
- %t
-
object_id of the thread.
-
#time(value = nil) ⇒ Object
- %r
-
the time in milliseconds since the program started.
- #to_scheme_opts ⇒ Object
- #warn(value = nil) ⇒ Object
- #warn_line(value = nil) ⇒ Object
Constructor Details
#initialize(*args, &build) ⇒ ColorsData
Returns a new instance of ColorsData.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/logsly/colors.rb', line 30 def initialize(*args, &build) self.instance_exec(*args, &build) @properties = properties.map{ |p| self.send(p) } @method = self.method_name @level_settings = levels.map{ |l| self.send(l) } @line_settings = levels.map{ |l| self.send("#{l}_line") } if has_level_settings? && has_line_settings? raise ArgumentError, "can't set line and level settings in the same scheme" end end |
Instance Method Details
#date(value = nil) ⇒ Object
- %d
-
datestamp
104 105 106 107 |
# File 'lib/logsly/colors.rb', line 104 def date(value = nil) @date = value if !value.nil? @date end |
#debug(value = nil) ⇒ Object
color for the level text only
45 46 47 48 |
# File 'lib/logsly/colors.rb', line 45 def debug(value = nil) @debug = value if !value.nil? @debug end |
#debug_line(value = nil) ⇒ Object
color for the entire log message based on the value of the log level
72 73 74 75 |
# File 'lib/logsly/colors.rb', line 72 def debug_line(value = nil) @debug_line = value if !value.nil? @debug_line end |
#error(value = nil) ⇒ Object
60 61 62 63 |
# File 'lib/logsly/colors.rb', line 60 def error(value = nil) @error = value if !value.nil? @error end |
#error_line(value = nil) ⇒ Object
87 88 89 90 |
# File 'lib/logsly/colors.rb', line 87 def error_line(value = nil) @error_line = value if !value.nil? @error_line end |
#fatal(value = nil) ⇒ Object
65 66 67 68 |
# File 'lib/logsly/colors.rb', line 65 def fatal(value = nil) @fatal = value if !value.nil? @fatal end |
#fatal_line(value = nil) ⇒ Object
92 93 94 95 |
# File 'lib/logsly/colors.rb', line 92 def fatal_line(value = nil) @fatal_line = value if !value.nil? @fatal_line end |
#file(value = nil) ⇒ Object
- %F
-
filename where the logging request was issued
140 141 142 143 |
# File 'lib/logsly/colors.rb', line 140 def file(value = nil) @file = value if !value.nil? @file end |
#info(value = nil) ⇒ Object
50 51 52 53 |
# File 'lib/logsly/colors.rb', line 50 def info(value = nil) @info = value if !value.nil? @info end |
#info_line(value = nil) ⇒ Object
77 78 79 80 |
# File 'lib/logsly/colors.rb', line 77 def info_line(value = nil) @info_line = value if !value.nil? @info_line end |
#line(value = nil) ⇒ Object
- %L
-
line number where the logging request was issued
146 147 148 149 |
# File 'lib/logsly/colors.rb', line 146 def line(value = nil) @line = value if !value.nil? @line end |
#logger(value = nil) ⇒ Object
- %c
-
name of the logger that generate the log event
98 99 100 101 |
# File 'lib/logsly/colors.rb', line 98 def logger(value = nil) @logger = value if !value.nil? @logger end |
#message(value = nil) ⇒ Object
- %m
-
the user supplied log message
110 111 112 113 |
# File 'lib/logsly/colors.rb', line 110 def (value = nil) @message = value if !value.nil? @message end |
#method_name(value = nil) ⇒ Object
- %M
-
method name where the logging request was issued
152 153 154 155 |
# File 'lib/logsly/colors.rb', line 152 def method_name(value = nil) @method_name = value if !value.nil? @method_name end |
#pid(value = nil) ⇒ Object
- %p
-
PID of the current process
116 117 118 119 |
# File 'lib/logsly/colors.rb', line 116 def pid(value = nil) @pid = value if !value.nil? @pid end |
#thread(value = nil) ⇒ Object
- %T
-
the name of the thread Thread.current
128 129 130 131 |
# File 'lib/logsly/colors.rb', line 128 def thread(value = nil) @thread = value if !value.nil? @thread end |
#thread_id(value = nil) ⇒ Object
- %t
-
object_id of the thread
134 135 136 137 |
# File 'lib/logsly/colors.rb', line 134 def thread_id(value = nil) @thread_id = value if !value.nil? @thread_id end |
#time(value = nil) ⇒ Object
- %r
-
the time in milliseconds since the program started
122 123 124 125 |
# File 'lib/logsly/colors.rb', line 122 def time(value = nil) @time = value if !value.nil? @time end |
#to_scheme_opts ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/logsly/colors.rb', line 157 def to_scheme_opts Hash.new.tap do |opts| # set general properties properties.each_with_index do |property, idx| opts[property] = @properties[idx] if @properties[idx] end # set special properties (reserved names) opts[:method] = @method if @method # set level settings - only add :levels key if one exists if has_level_settings? opts[:levels] = {} levels.each_with_index do |level, idx| opts[:levels][level] = @level_settings[idx] if @level_settings[idx] end end # set line-level settings - only :lines key if one exists if has_line_settings? opts[:lines] = {} levels.each_with_index do |level, idx| opts[:lines][level] = @line_settings[idx] if @line_settings[idx] end end end end |
#warn(value = nil) ⇒ Object
55 56 57 58 |
# File 'lib/logsly/colors.rb', line 55 def warn(value = nil) @warn = value if !value.nil? @warn end |
#warn_line(value = nil) ⇒ Object
82 83 84 85 |
# File 'lib/logsly/colors.rb', line 82 def warn_line(value = nil) @warn_line = value if !value.nil? @warn_line end |