Class: OspDeploy::ThreadInfoLogger
- Inherits:
-
Logger
- Object
- Logger
- OspDeploy::ThreadInfoLogger
- Defined in:
- lib/osp_deploy/thread_info_logger.rb
Constant Summary collapse
- SERVERITY_COLORS =
{ 'DEBUG' => "\033[37m", # Light Gray 'INFO' => "\033[32m", # Green 'WARN' => "\033[33m", # Yellow 'ERROR' => "\033[31m" # Red }
Instance Attribute Summary collapse
-
#disable_ansi_colors ⇒ Object
Returns the value of attribute disable_ansi_colors.
Instance Method Summary collapse
Instance Attribute Details
#disable_ansi_colors ⇒ Object
Returns the value of attribute disable_ansi_colors.
15 16 17 |
# File 'lib/osp_deploy/thread_info_logger.rb', line 15 def disable_ansi_colors @disable_ansi_colors end |
Instance Method Details
#format_message(severity, timestamp, progname, msg) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/osp_deploy/thread_info_logger.rb', line 17 def (severity, , progname, msg) thread_info = Thread.current[:log_prefix] prefix = "%s %-5s %s - " % [.strftime('%H:%M:%S'), severity, thread_info] # Einfügen Zeilenumbruch bei langen Messages width = 120 log_msg = insert_line_feeds(msg, width, prefix) log_msg = colorize(log_msg, SERVERITY_COLORS[severity]) unless @disable_ansi_colors "#{log_msg}\n" end |