Browse Source

Do not override Ruby send method

This breaks the contract of Ruby logging, the change if accepted into
the mainline will require major version bump.
master
Lukas Zapletal 2 months ago
parent
commit
198bac10a2
10 changed files with 43 additions and 39 deletions
  1. +3
    -6
      .travis.yml
  2. +6
    -0
      CHANGELOG.md
  3. +1
    -3
      README.md
  4. +26
    -1
      Rakefile
  5. +2
    -2
      journald-logger.gemspec
  6. +2
    -2
      lib/journald/classes/logger.rb
  7. +1
    -1
      lib/journald/modules/exceptionable.rb
  8. +1
    -1
      lib/journald/modules/loggable.rb
  9. +1
    -1
      lib/journald/modules/version.rb
  10. +0
    -22
      rakelib/rufo.rake

+ 3
- 6
.travis.yml View File

@@ -1,13 +1,10 @@
language: ruby
before_install:
- sudo apt-get install -y libsystemd-journal-dev
- sudo apt-get install -y libsystemd-dev
install: "bundle install"
rvm:
- 2.0.0
- 2.1.0
- 2.2.0
- 2.3.0
- 2.4.0
- 2.6.0
script:
- bundle exec rspec
- bundle exec rake build
- bundle exec rake

+ 6
- 0
CHANGELOG.md View File

@@ -1,5 +1,11 @@
# Changelog

## v3.0.0

*December 3, 2019*

- Do not override Ruby send method (API change)

## v2.0.4

*October 9, 2018*

+ 1
- 3
README.md View File

@@ -1,7 +1,5 @@
# journald-logger

[![Build Status](https://travis-ci.org/theforeman/journald-logger.svg?branch=master)](https://travis-ci.org/theforeman/journald-logger)

A Logger drop-in replacement that logs directly to systemd-journal with some additional features

## Usage
@@ -73,7 +71,7 @@ letters, numbers, underscores, cannot begin with underscore. Library upcases all
Two methods which look similarly to native systemd-journal api

```ruby
logger.send(
logger.send_message(
message: 'hi!',
priority: Journald::LOG_NOTICE,
any_field: 'any_value',

+ 26
- 1
Rakefile View File

@@ -5,4 +5,29 @@ require "rubocop/rake_task"
RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new

task :default => [:spec, :rubocop, :'rufo:check']
if Gem::Version.new(RUBY_VERSION) > Gem::Version.new("2.0")
namespace :rufo do
require "rufo"

def rufo_command(*switches, rake_args)
files_or_dirs = rake_args[:files_or_dirs] || "."
args = switches + files_or_dirs.split(" ")
Rufo::Command.run(args)
end

desc "Format Ruby code in current directory"
task :run, [:files_or_dirs] do |_task, rake_args|
rufo_command(rake_args)
end

desc "Check that no formatting changes are produced"
task :check, [:files_or_dirs] do |_task, rake_args|
rufo_command("--check", rake_args)
end
end

task :default => [:spec, :rubocop, :'rufo:check']
else
# rufo is no longer Ruby 2.0 compatible yet we want to support old Ruby
task :default => [:spec, :rubocop]
end

+ 2
- 2
journald-logger.gemspec View File

@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency "journald-native", "~> 1.0"

spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "bundler"
spec.add_development_dependency "rake"
spec.add_development_dependency "rufo"
spec.add_development_dependency "rubocop", "~> 0.50.0"
spec.add_development_dependency "rspec", "~> 3.4"
spec.add_development_dependency "rspec"
spec.add_development_dependency "simplecov"
end

+ 2
- 2
lib/journald/classes/logger.rb View File

@@ -28,13 +28,13 @@ module Journald
# systemd-journal style

# send systemd-journal message
def send(hash)
def send_message(hash)
hash_to_send = @tags.merge(hash)
real_send(hash_to_send)
end

def print(priority, message)
send(
send_message(
priority: priority,
message: message,
)

+ 1
- 1
lib/journald/modules/exceptionable.rb View File

@@ -18,7 +18,7 @@ module Journald

tag_trace_location(e.backtrace_locations[0]) if bt

send(
send_message(
priority: priority,
message: "Exception #{e.inspect}",
gem_logger_message_type: is_cause ? "ExceptionCause" : "Exception",

+ 1
- 1
lib/journald/modules/loggable.rb View File

@@ -27,7 +27,7 @@ module Journald
end
end

send(
send_message(
priority: priority,
message: message,
syslog_identifier: progname,

+ 1
- 1
lib/journald/modules/version.rb View File

@@ -1,5 +1,5 @@
module Journald
class Logger
VERSION = "2.0.4"
VERSION = "3.0.0"
end
end

+ 0
- 22
rakelib/rufo.rake View File

@@ -1,22 +0,0 @@
desc "Alias for `rake rufo:run`"
task :rufo => ["rufo:run"]

namespace :rufo do
require "rufo"

def rufo_command(*switches, rake_args)
files_or_dirs = rake_args[:files_or_dirs] || "."
args = switches + files_or_dirs.split(" ")
Rufo::Command.run(args)
end

desc "Format Ruby code in current directory"
task :run, [:files_or_dirs] do |_task, rake_args|
rufo_command(rake_args)
end

desc "Check that no formatting changes are produced"
task :check, [:files_or_dirs] do |_task, rake_args|
rufo_command("--check", rake_args)
end
end

Loading…
Cancel
Save