Class: Steno::Sink::Syslog
- Includes:
- Singleton
- Defined in:
- lib/steno/sink/syslog.rb
Constant Summary collapse
- MAX_MESSAGE_SIZE =
1024 * 3
- TRUNCATE_POSTFIX =
"..."
- LOG_LEVEL_MAP =
{ :fatal => Syslog::LOG_CRIT, :error => Syslog::LOG_ERR, :warn => Syslog::LOG_WARNING, :info => Syslog::LOG_INFO, :debug => Syslog::LOG_DEBUG, :debug1 => Syslog::LOG_DEBUG, :debug2 => Syslog::LOG_DEBUG, }
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #add_record(record) ⇒ Object
- #flush ⇒ Object
-
#initialize ⇒ Syslog
constructor
A new instance of Syslog.
- #open(identity) ⇒ Object
Constructor Details
#initialize ⇒ Syslog
Returns a new instance of Syslog.
24 25 26 27 28 29 |
# File 'lib/steno/sink/syslog.rb', line 24 def initialize super @syslog = nil @syslog_lock = Mutex.new end |
Instance Method Details
#add_record(record) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/steno/sink/syslog.rb', line 36 def add_record(record) record = truncate_record(record) msg = @codec.encode_record(record) pri = LOG_LEVEL_MAP[record.log_level] @syslog_lock.synchronize { @syslog.log(pri, "%s", msg) } end |
#flush ⇒ Object
43 44 45 |
# File 'lib/steno/sink/syslog.rb', line 43 def flush nil end |
#open(identity) ⇒ Object
31 32 33 34 |
# File 'lib/steno/sink/syslog.rb', line 31 def open(identity) @identity = identity @syslog = Syslog.open(@identity, Syslog::LOG_PID, Syslog::LOG_USER) end |