Project

General

Profile

Bug #7065

Syslog::Logger should have a formatter

Added by tenderlovemaking (Aaron Patterson) about 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
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

Associated revisions

Revision e0bff650
Added by knu (Akinori MUSHA) about 7 years ago

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37039
Added by knu (Akinori MUSHA) about 7 years ago

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

Revision 37039
Added by knu (Akinori MUSHA) about 7 years ago

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

Revision 37039
Added by knu (Akinori MUSHA) about 7 years ago

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

Revision 37039
Added by knu (Akinori MUSHA) about 7 years ago

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

Revision 37039
Added by knu (Akinori MUSHA) about 7 years ago

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

Revision 37039
Added by knu (Akinori MUSHA) about 7 years ago

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

History

Updated by bitsweat (Jeremy Daer) about 7 years ago

I tested this in my application. Works as expected.

Updated by luislavena (Luis Lavena) about 7 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) about 7 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) about 7 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.

#5

Updated by knu (Akinori MUSHA) about 7 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.

Also available in: Atom PDF