Project

General

Profile

Actions

Bug #7065

closed

Syslog::Logger should have a formatter

Added by tenderlovemaking (Aaron Patterson) over 11 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-09-24 trunk 37026) [x86_64-darwin12.2.0]
Backport:
[ruby-core:47681]

Description

Hi, Syslog::Logger should have a formatter so that it can behave similar to the regular Logger class. I've attached a patch with tests to implement the formatter.

Thanks!


Files

syslog_formatter.patch (3.77 KB) syslog_formatter.patch tenderlovemaking (Aaron Patterson), 09/25/2012 07:14 AM

Updated by bitsweat (Jeremy Daer) over 11 years ago

I tested this in my application. Works as expected.

Updated by luislavena (Luis Lavena) over 11 years ago

How about moving ansi regexp as constant so regexp object doesn't get allocated on every formatter.call?

Updated by Eregon (Benoit Daloze) over 11 years ago

luislavena (Luis Lavena) wrote:

How about moving ansi regexp as constant so regexp object doesn't get allocated on every formatter.call?

If I'm not mistaken this is unnecessary, as "static" (without #{...}) Regexps are created only once (because they are immutable):

class Formatter
  def clean
    /\e\[[0-9;]*m/
  end

  def clean2
    />#{'a'*2}</
  end
end

2.times { p Formatter.new.clean.object_id }
puts
2.times { p Formatter.new.clean2.object_id }

Updated by luislavena (Luis Lavena) over 11 years ago

  • Status changed from Open to Assigned

Eregon (Benoit Daloze) wrote:

If I'm not mistaken this is unnecessary, as "static" (without #{...}) Regexps are created only once (because they are immutable):

You're correct, I should stop responding to issues after 10pm.

Actions #5

Updated by knu (Akinori MUSHA) over 11 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r37039.
Aaron, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ext/syslog/lib/syslog/logger.rb: add a formatter to the
    Syslog::Logger object. [Bug #7065]
  • test/syslog/test_syslog_logger.rb: ditto.
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0