Skip to content

Commit ab20d0c

Browse files
authored
Merge pull request #15 from voxik/ruby-3.3
Add Ruby 3.3 into CI and use `logger` tool for logging
2 parents 8eb475e + c9d6503 commit ab20d0c

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

.github/workflows/ruby.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
ruby-version: ['2.5', '3.0', '3.1', '3.2']
19+
ruby-version: ['2.5', '3.0', '3.1', '3.2', '3.3']
2020

2121
steps:
2222
- uses: actions/checkout@v4

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ gem "abrt", :require => false
1818

1919
line into your *Gemfile*.
2020

21+
### Dependencies
22+
23+
This library is using `logger` command from util-linux for logging purposes.
24+
Please make sure it is available on your system for proper functionality.
25+
2126
## Usage
2227

2328
There are several ways how to run any application with ABRT handler enabled.

lib/abrt/handler.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require 'socket'
2-
require 'syslog'
2+
require_relative 'util_linux_logger'
33
require_relative 'exception'
44

55
module ABRT
@@ -16,7 +16,7 @@ def self.handle_exception(exception)
1616
private
1717

1818
def self.syslog
19-
@syslog ||= Syslog.open 'abrt'
19+
@syslog ||= UtilLinuxLogger.open 'abrt'
2020
end
2121

2222
def self.report(exception, io = nil)

lib/abrt/util_linux_logger.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# UtilLinuxLogger is small utility class intended to be drop in replacement for
2+
# Syslog. It uses `logger` command from util-linux project to provide system
3+
# logging facilities.
4+
#
5+
# It implements just minimal interface required by ABRT project.
6+
class UtilLinuxLogger
7+
# :yields: syslog
8+
#
9+
# Open the UtilLinuxLoggersyslog facility.
10+
#
11+
# `ident` is a String which identifies the calling program.
12+
def self.open(ident)
13+
self.new(ident)
14+
end
15+
16+
def initialize(ident)
17+
@ident = ident
18+
end
19+
20+
def notice(format_string, *arguments)
21+
log 'user.notice', format_string, *arguments
22+
end
23+
24+
def err(format_string, *arguments)
25+
log 'user.err', format_string, *arguments
26+
end
27+
28+
private
29+
def log(priority, format_string, *arguments)
30+
IO.popen "logger -p #{priority} -t #{@ident} --socket-errors=off", 'w' do |io|
31+
io.write sprintf(format_string, *arguments)
32+
end
33+
end
34+
end

0 commit comments

Comments
 (0)