Sha256: 35add890a4bb1365b49968cd0726fade6adb72c6ef800cae1851f5bc88e5514e
Contents?: true
Size: 1.68 KB
Versions: 3
Compression:
Stored size: 1.68 KB
Contents
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. # Copyright:: Copyright (c) 2004, 2005 TTK team. All rights reserved. # License:: LGPL # $Id: to_ttk_log.rb 575 2005-04-14 10:22:30Z polrop $ module TTK class Logger # These extensions add to any object, a proper way # to inject an object in a result like Logger. # # Example: # # include TTK # anObject.to_ttk_log(Logger.new(Dumper::Yaml.new(STDERR))) # module ToTTKLog class ::Object # :nodoc: def to_ttk_log ( log ) log.new_leaf(self) end end # class ::Object class ::Hash # :nodoc: def hash_to_ttk_log ( log, type ) each do |k,v| if v.is_a? Array and v.all? { |x| x.is_a? Hash } log.new_node(k, :seq) do v.each do |x| x.to_ttk_log(log) end end else log.new_node(k, type) do v.to_ttk_log(log) end end end end def to_ttk_log ( log ) hash_to_ttk_log(log, :map) end end # class ::Hash class ::OHash < ::Hash # :nodoc: def to_ttk_log ( log ) hash_to_ttk_log(log, :seq) end end # class ::OHash # WARNING: Do not implement Array#to_ttk_log it doesn't make sense. class ::Exception # :nodoc: def to_ttk_log ( log ) if log.severity_level <= Severity::DEBUG long_pp.to_ttk_log(log) else short_pp.to_ttk_log(log) end end end # class ::Exception end # module ToTTKLog end # class Logger end # module TTK
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ttk-0.1.576 | lib/ttk/logger/to_ttk_log.rb |
ttk-0.1.580 | lib/ttk/logger/to_ttk_log.rb |
ttk-0.1.579 | lib/ttk/logger/to_ttk_log.rb |