Sha256: 637edd79b7889ea982681486a6858983318163e0c4ca8b9df88fda0ec8bde2e7
Contents?: true
Size: 1.18 KB
Versions: 21
Compression:
Stored size: 1.18 KB
Contents
# -*- coding: utf-8 -*- class Remnant class Template class Trace def start(template_name) rendering = Remnant::Template::Rendering.new(template_name) rendering.start_time = Time.now @current.add(rendering) @current = rendering end def finished(template_name) @current.end_time = Time.now @current = @current.parent end def initialize @current = root end def total_time root.child_time end def root @root ||= Remnant::Template::Rendering.new('root') end def log(logger, rendering) rendering.results.map do |key, result| # line = Remnant.color line += "#{' ' * (result['depth'] - 1)}#{result['depth'] > 1 ? '└ ' : ''}" line += "#{result['time'].to_i}ms (#{result['exclusive'].to_i}ms)" line += Remnant.color(true) line += ' ' * ((line.size >= 50 ? 10 : 50 - line.size) - (result['depth'] == 1 ? 2 : 0)) line += "#{key}" logger.info line rendering.children.map do |child| log(logger, child) end end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems