Class: KubeDeployTools::FormattedLogger
- Includes:
- DeferredSummaryLogging
- Defined in:
- lib/kube_deploy_tools/formatted_logger.rb
Instance Attribute Summary
Attributes included from DeferredSummaryLogging
Class Method Summary collapse
Methods included from DeferredSummaryLogging
#blank_line, #heading, #initialize, #phase_heading, #print_summary, #reset
Class Method Details
.build(context: nil, namespace: nil, stream: $stderr) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/kube_deploy_tools/formatted_logger.rb', line 12 def self.build(context: nil, namespace: nil, stream: $stderr) l = new(stream) l.level = level_from_env l.formatter = proc do |severity, datetime, _progname, msg| middle = context ? "[#{context}]" : "" if ! namespace.nil? && namespace != 'default' middle += "[#{namespace}]" end dt = datetime.strftime('%F %T') colorized_line = ColorizedString.new("[#{severity}][#{dt}]#{middle} #{msg}\n") case severity when "FATAL" ColorizedString.new("[#{severity}][#{dt}]#{middle} ").red + "#{msg}\n" when "ERROR" colorized_line.red when "WARN" colorized_line.yellow else colorized_line end end l end |