-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathutil_linux_logger.rb
More file actions
34 lines (30 loc) · 895 Bytes
/
util_linux_logger.rb
File metadata and controls
34 lines (30 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# UtilLinuxLogger is small utility class intended to be drop in replacement for
# Syslog. It uses `logger` command from util-linux project to provide system
# logging facilities.
#
# It implements just minimal interface required by ABRT project.
class UtilLinuxLogger
# :yields: syslog
#
# Open the UtilLinuxLoggersyslog facility.
#
# `ident` is a String which identifies the calling program.
def self.open(ident)
self.new(ident)
end
def initialize(ident)
@ident = ident
end
def notice(format_string, *arguments)
log 'user.notice', format_string, *arguments
end
def err(format_string, *arguments)
log 'user.err', format_string, *arguments
end
private
def log(priority, format_string, *arguments)
IO.popen "logger -p #{priority} -t #{@ident} --socket-errors=off", 'w' do |io|
io.write sprintf(format_string, *arguments)
end
end
end