# File /home/cepheus/projects/prep/log4r-1.0.0/src/log4r/patternformatter.rb, line 82 def PatternFormatter.create_format_methods(pf) # first, define the format_date method if pf.date_method module_eval "def pf.format_date; Time.now.#{pf.date_method}; end" else module_eval " def pf.format_date\n Time.now.strftime \"\#{pf.date_pattern}\"\n end\n" end # and now the main format method ebuff = "def pf.format(level, logger, tracer, data)\n sprintf(\" _pattern = pf.pattern.dup args = [] # the args to sprintf which we'll append to ebuff lastly while true # work on each match in turn match = DirectiveRegexp.match _pattern ebuff += match[1] unless match[1].empty? break if match[2].nil? # deal with the directive by inserting a %#.#s where %#.# is copied # directy from the match ebuff += match[3] + "s" args << DirectiveTable[match[5]] # cull the data for our argument list break if match[6].empty? _pattern = match[6] end ebuff += '\n", ' + args.join(', ') + ")\n" ebuff += "end\n" module_eval ebuff end