From ae31cc838a576794309209ec3ea83a18d12eb14e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Fri, 1 Aug 2025 13:04:20 +0200 Subject: [PATCH 1/2] Use custom `UtilLinuxLogger` instead `syslog` `syslog` used to be part of StdLib. But beginning with Ruby 3.4, it was extracted into default gems. This is problematic when Ruby is executed with `--disable-gems`, because there is no easy way to require `syslog`. Therefore, this commit introduces custom `UtilLinuxLogger`. This use `logger` command from util-linux and implemnts just minimal `Syslog` interface required. While this could have been used just as a fallback, when `syslog` can't be required, it will be easier to use it every time. Fixes #12 --- README.md | 5 +++++ lib/abrt/handler.rb | 4 ++-- lib/abrt/util_linux_logger.rb | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 lib/abrt/util_linux_logger.rb diff --git a/README.md b/README.md index 78f7637..00cca53 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,11 @@ gem "abrt", :require => false line into your *Gemfile*. +### Dependencies + +This library is using `logger` command from util-linux for logging purposes. +Please make sure it is available on your system for proper functionality. + ## Usage There are several ways how to run any application with ABRT handler enabled. diff --git a/lib/abrt/handler.rb b/lib/abrt/handler.rb index e116fde..27ee525 100644 --- a/lib/abrt/handler.rb +++ b/lib/abrt/handler.rb @@ -1,5 +1,5 @@ require 'socket' -require 'syslog' +require_relative 'util_linux_logger' require_relative 'exception' module ABRT @@ -16,7 +16,7 @@ def self.handle_exception(exception) private def self.syslog - @syslog ||= Syslog.open 'abrt' + @syslog ||= UtilLinuxLogger.open 'abrt' end def self.report(exception, io = nil) diff --git a/lib/abrt/util_linux_logger.rb b/lib/abrt/util_linux_logger.rb new file mode 100644 index 0000000..32b85fa --- /dev/null +++ b/lib/abrt/util_linux_logger.rb @@ -0,0 +1,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 From c9d65038d2feccdf9f953f383f2d5ab512eda15d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Fri, 1 Aug 2025 13:53:35 +0200 Subject: [PATCH 2/2] Add Ruby 3.3 into CI --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 43941da..7b1828b 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: ['2.5', '3.0', '3.1', '3.2'] + ruby-version: ['2.5', '3.0', '3.1', '3.2', '3.3'] steps: - uses: actions/checkout@v4