class Evrone::CI::Common::TaggedLogging::Formatter

Constants

Format

Public Instance Methods

call(severity, time, progname, msg) click to toggle source
# File lib/evrone/ci/common/tagged_logging.rb, line 13
def call(severity, time, progname, msg)
  Format % [format_datetime(time),
            severity[0...1],
            msg2str("#{tags_text}#{msg}")]
end
clear_tags!() click to toggle source
# File lib/evrone/ci/common/tagged_logging.rb, line 40
def clear_tags!
  current_tags.clear
end
current_tags() click to toggle source
# File lib/evrone/ci/common/tagged_logging.rb, line 44
def current_tags
  Thread.current[:activesupport_tagged_logging_tags] ||= []
end
pop_tags(size = 1) click to toggle source
# File lib/evrone/ci/common/tagged_logging.rb, line 36
def pop_tags(size = 1)
  current_tags.pop size
end
push_tags(*tags) click to toggle source
# File lib/evrone/ci/common/tagged_logging.rb, line 30
def push_tags(*tags)
  tags.flatten.reject{|i| i.to_s.strip.empty? }.tap do |new_tags|
    current_tags.concat new_tags
  end
end
tagged(*tags) { |self| ... } click to toggle source
# File lib/evrone/ci/common/tagged_logging.rb, line 23
def tagged(*tags)
  new_tags = push_tags(*tags)
  yield self
ensure
  pop_tags(new_tags.size)
end
thread_id() click to toggle source
# File lib/evrone/ci/common/tagged_logging.rb, line 19
def thread_id
  Thread.current.object_id
end

Private Instance Methods

tags_text() click to toggle source
# File lib/evrone/ci/common/tagged_logging.rb, line 50
def tags_text
  tags = current_tags
  if tags.any?
    tags.collect { |tag| "[#{tag}] " }.join
  end
end