lib/syslogger.rb in syslogger-1.5.1 vs lib/syslogger.rb in syslogger-1.6.0
- old
+ new
@@ -2,13 +2,14 @@
require 'logger'
require 'thread'
class Syslogger
- VERSION = "1.5.1"
+ VERSION = "1.6.0"
- attr_reader :level, :ident, :options, :facility, :max_octets, :formatter
+ attr_reader :level, :ident, :options, :facility, :max_octets
+ attr_accessor :formatter
MAPPING = {
Logger::DEBUG => Syslog::LOG_DEBUG,
Logger::INFO => Syslog::LOG_INFO,
Logger::WARN => Syslog::LOG_WARNING,
@@ -93,10 +94,11 @@
communication = clean(message || block && block.call)
if self.max_octets
buffer = ""
communication.bytes do |byte|
buffer.concat(byte)
- if buffer.bytesize >= self.max_octets
+ # if the last byte we added is potentially part of an escape, we'll go ahead and add another byte
+ if buffer.bytesize >= self.max_octets && !['%'.ord,'\\'.ord].include?(byte)
s.log(MAPPING[severity],buffer)
buffer = ""
end
end
s.log(MAPPING[severity],buffer) unless buffer.empty?