Bug #7065
closedSyslog::Logger should have a formatter
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
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.
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.