Class: AxeLogger
Defined Under Namespace
Modules: Colors
Constant Summary collapse
- COLOR_CONFIG =
{ :debug => GREEN, :info => BLUE, :warn => PURPLE, :error => RED }
- STACK_LEVEL =
1
- STACK_EXP =
/(?<file>.+):(?<line>\d+):.*`(?<func>.+)'/
Constants included from Colors
Colors::BLUE, Colors::GREEN, Colors::PURPLE, Colors::RED
Instance Attribute Summary collapse
-
#date_format ⇒ Object
Returns the value of attribute date_format.
Instance Method Summary collapse
- #format_message(severity, datetime, progname, msg) ⇒ Object
-
#initialize(*opts) ⇒ AxeLogger
constructor
A new instance of AxeLogger.
Constructor Details
#initialize(*opts) ⇒ AxeLogger
Returns a new instance of AxeLogger.
21 22 23 24 |
# File 'lib/axe_logger.rb', line 21 def initialize (*opts) @date_format = '%m/%d/%Y %H:%M:%S' super end |
Instance Attribute Details
#date_format ⇒ Object
Returns the value of attribute date_format.
20 21 22 |
# File 'lib/axe_logger.rb', line 20 def date_format @date_format end |
Instance Method Details
#format_message(severity, datetime, progname, msg) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/axe_logger.rb', line 26 def severity, datetime, progname, msg m = STACK_EXP.match caller[STACK_LEVEL+1].split('/').last time = datetime.strftime date_format color = COLOR_CONFIG[severity.downcase.to_sym] string_with_color("#{time} #{m[:file]}:#{m[:line]} (#{m[:func]}): ", color) + "#{msg}\n" end |