syslog 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52f533359f850a1836a3161e0f87512e7db229c3f2914766e55797e60a283806
4
- data.tar.gz: 28c1054089a598e4784387f3a98f192189683b5673f46355694f1561d2d4c103
3
+ metadata.gz: 83c32c413293d9c1902db61758c3f53403e5e0f1218a8ec8fa1477eb63413559
4
+ data.tar.gz: 49df9dd2ac69c88ebd80c2b3d572066c65382295e791ad688aa30eb758667e02
5
5
  SHA512:
6
- metadata.gz: a86150afc0aa20e6af3ef8cca7f135030b58aeedec37dca817e0747a2c67af56712af042f0265b9f4968a171690ca03d4f4b1c1ac86b9d0361aa2224d71c65fc
7
- data.tar.gz: b931344ddf90fa04c8a84361a032fd864e7572c0d5efbd0659bbb667b9804ba1a44b59615f57645536b2e47ed33b3d763a81c332d6f1a6b9735814d0d0df84b6
6
+ metadata.gz: ca7483657ae6615cffeedd4fbf9641863eae3ac1e7f1f2cfddf3a634fc99c16e0dc8661d72c247e359654e56108c6b907465e97a76e653b328f2a42c307b06aa
7
+ data.tar.gz: 3df3ce9c54557473f754e57f7792419ca2c9b52301b8c8cd14a786238de2a052a448ae9de4f9b6b8dc10bd1d1bdc38ffde9611a3612a76f87e8663c3671e9304
@@ -0,0 +1,4 @@
1
+ changelog:
2
+ exclude:
3
+ labels:
4
+ - dependencies # Added by Dependabot
@@ -23,24 +23,24 @@ jobs:
23
23
 
24
24
  steps:
25
25
  - name: Harden Runner
26
- uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
26
+ uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
27
27
  with:
28
28
  egress-policy: audit
29
29
 
30
- - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
30
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31
31
 
32
32
  - name: Set up Ruby
33
- uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 # v1.190.0
33
+ uses: ruby/setup-ruby@90be1154f987f4dc0fe0dd0feedac9e473aa4ba8 # v1.286.0
34
34
  with:
35
35
  bundler-cache: true
36
36
  ruby-version: ruby
37
37
 
38
38
  - name: Publish to RubyGems
39
- uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1
39
+ uses: rubygems/release-gem@1c162a739e8b4cb21a676e97b087e8268d8fc40b # v1.1.2
40
40
 
41
41
  - name: Create GitHub release
42
42
  run: |
43
43
  tag_name="$(git describe --tags --abbrev=0)"
44
44
  gh release create "${tag_name}" --verify-tag --generate-notes
45
45
  env:
46
- GITHUB_TOKEN: ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}
46
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -3,21 +3,31 @@ name: build
3
3
  on: [push, pull_request]
4
4
 
5
5
  jobs:
6
+ ruby-versions:
7
+ uses: ruby/actions/.github/workflows/ruby_versions.yml@master
8
+ with:
9
+ min_version: 2.5
10
+
6
11
  build:
12
+ needs: ruby-versions
7
13
  name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
14
  strategy:
15
+ fail-fast: false
9
16
  matrix:
10
- ruby: [ 2.7, 2.6, 2.5, head ]
17
+ ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
11
18
  os: [ ubuntu-latest, macos-latest, windows-latest ]
12
19
  exclude:
13
20
  - { os: macos-latest, ruby: '2.5' }
21
+ - { os: windows-latest, ruby: 'truffleruby' }
22
+ - { os: windows-latest, ruby: 'truffleruby-head' }
14
23
  include:
15
- - { os: macos-13, ruby: '2.5' }
24
+ - { os: macos-15-intel, ruby: '2.5' }
25
+ - { os: macos-15-intel, ruby: '3.4' }
16
26
  runs-on: ${{ matrix.os }}
17
27
  steps:
18
- - uses: actions/checkout@v4
28
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
19
29
  - name: Set up Ruby
20
- uses: ruby/setup-ruby@v1
30
+ uses: ruby/setup-ruby@90be1154f987f4dc0fe0dd0feedac9e473aa4ba8 # v1.286.0
21
31
  with:
22
32
  ruby-version: ${{ matrix.ruby }}
23
33
  - name: Install dependencies
data/Rakefile CHANGED
@@ -7,14 +7,20 @@ Rake::TestTask.new(:test) do |t|
7
7
  t.test_files = FileList["test/**/test_*.rb"]
8
8
  end
9
9
 
10
- require 'rake/extensiontask'
11
- Rake::ExtensionTask.new("syslog_ext") do |ext|
12
- ext.ext_dir = 'ext/syslog'
10
+ if RUBY_ENGINE == 'jruby'
11
+ # nothing to compile for JRuby
12
+ task :compile do end
13
+ else
14
+ require 'rake/extensiontask'
15
+ Rake::ExtensionTask.new("syslog_ext") do |ext|
16
+ ext.ext_dir = 'ext/syslog'
13
17
 
14
- # In contrast to "gem install" a "rake compile" is expecting the C-ext file even on Windows.
15
- # Work around by creating a dummy so file.
16
- task "#{ext.tmp_dir}/#{ext.platform}/stage/lib" do |t|
17
- touch "#{ext.tmp_dir}/#{ext.platform}/#{ext.name}/#{RUBY_VERSION}/#{ext.name}.so"
18
+ # In contrast to "gem install" a "rake compile" is expecting the C-ext file even on Windows.
19
+ # Work around by creating a dummy so file.
20
+ task "#{ext.tmp_dir}/#{ext.platform}/stage/lib" do |t|
21
+ touch "#{ext.tmp_dir}/#{ext.platform}/#{ext.name}/#{RUBY_VERSION}/#{ext.name}.so"
22
+ end
18
23
  end
19
24
  end
25
+
20
26
  task :default => :test
@@ -14,7 +14,7 @@ def windows?
14
14
  RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
15
15
  end
16
16
 
17
- if windows?
17
+ if windows? || RUBY_ENGINE == 'jruby'
18
18
  generate_dummy_makefile
19
19
  else
20
20
  have_library("log") # for Android
data/ext/syslog/syslog.c CHANGED
@@ -12,7 +12,7 @@
12
12
  #include "ruby/util.h"
13
13
  #include <syslog.h>
14
14
 
15
- #define SYSLOG_VERSION "0.3.0"
15
+ #define SYSLOG_VERSION "0.4.0"
16
16
 
17
17
  /* Syslog class */
18
18
  static VALUE mSyslog;
@@ -0,0 +1,364 @@
1
+ # Created by Ari Brown on 2008-02-23.
2
+ # For rubinius. All pwnage reserved.
3
+
4
+ # ** Syslog(Module)
5
+
6
+ # Included Modules: Syslog::Constants
7
+
8
+ # require 'syslog'
9
+
10
+ # A Simple wrapper for the UNIX syslog system calls that might be handy
11
+ # if you're writing a server in Ruby. For the details of the syslog(8)
12
+ # architecture and constants, see the syslog(3) manual page of your
13
+ # platform.
14
+ require 'ffi'
15
+
16
+ if FFI::Platform::IS_WINDOWS
17
+ raise LoadError, "Syslog not supported on this platform"
18
+ end
19
+
20
+ module Syslog
21
+ module Constants
22
+ Java::jnr.constants.platform.Syslog.values.each do |const|
23
+ next if const.name == '__UNKNOWN_CONSTANT__'
24
+ next if !const.defined?
25
+ const_set const.name, const.value
26
+ end
27
+ end
28
+ include Constants
29
+
30
+ module Level
31
+ if defined? Constants::LOG_EMERG
32
+ LOG_EMERG = Constants::LOG_EMERG
33
+
34
+ def emerg(*args)
35
+ Syslog.log(LOG_EMERG, *args)
36
+ end
37
+ end
38
+ if defined? Constants::LOG_ALERT
39
+ LOG_ALERT = Constants::LOG_ALERT
40
+
41
+ def alert(*args)
42
+ Syslog.log(LOG_ALERT, *args)
43
+ end
44
+ end
45
+ if defined? Constants::LOG_CRIT
46
+ LOG_CRIT = Constants::LOG_CRIT
47
+
48
+ def crit(*args)
49
+ Syslog.log(LOG_CRIT, *args)
50
+ end
51
+ end
52
+ if defined? Constants::LOG_ERR
53
+ LOG_ERR = Constants::LOG_ERR
54
+
55
+ def err(*args)
56
+ Syslog.log(LOG_ERR, *args)
57
+ end
58
+ end
59
+ if defined? Constants::LOG_WARNING
60
+ LOG_WARNING = Constants::LOG_WARNING
61
+
62
+ def warning(*args)
63
+ Syslog.log(LOG_WARNING, *args)
64
+ end
65
+ end
66
+ if defined? Constants::LOG_NOTICE
67
+ LOG_NOTICE = Constants::LOG_NOTICE
68
+
69
+ def notice(*args)
70
+ Syslog.log(LOG_NOTICE, *args)
71
+ end
72
+ end
73
+ if defined? Constants::LOG_INFO
74
+ LOG_INFO = Constants::LOG_INFO
75
+
76
+ def info(*args)
77
+ Syslog.log(LOG_INFO, *args)
78
+ end
79
+ end
80
+ if defined? Constants::LOG_DEBUG
81
+ LOG_DEBUG = Constants::LOG_DEBUG
82
+
83
+ def debug(*args)
84
+ syslog_write(LOG_DEBUG, *args)
85
+ end
86
+ end
87
+ end
88
+
89
+ module Facility
90
+ if defined? Constants::LOG_AUTH
91
+ LOG_AUTH = Constants::LOG_AUTH
92
+ end
93
+ if defined? Constants::LOG_AUTHPRIV
94
+ LOG_AUTHPRIV = Constants::LOG_AUTHPRIV
95
+ end
96
+ if defined? Constants::LOG_CONSOLE
97
+ LOG_CONSOLE = Constants::LOG_CONSOLE
98
+ end
99
+ if defined? Constants::LOG_CRON
100
+ LOG_CRON = Constants::LOG_CRON
101
+ end
102
+ if defined? Constants::LOG_DAEMON
103
+ LOG_DAEMON = Constants::LOG_DAEMON
104
+ end
105
+ if defined? Constants::LOG_FTP
106
+ LOG_FTP = Constants::LOG_FTP
107
+ end
108
+ if defined? Constants::LOG_KERN
109
+ LOG_KERN = Constants::LOG_KERN
110
+ end
111
+ if defined? Constants::LOG_LPR
112
+ LOG_LPR = Constants::LOG_LPR
113
+ end
114
+ if defined? Constants::LOG_MAIL
115
+ LOG_MAIL = Constants::LOG_MAIL
116
+ end
117
+ if defined? Constants::LOG_NEWS
118
+ LOG_NEWS = Constants::LOG_NEWS
119
+ end
120
+ if defined? Constants::LOG_NTP
121
+ LOG_NTP = Constants::LOG_NTP
122
+ end
123
+ if defined? Constants::LOG_SECURITY
124
+ LOG_SECURITY = Constants::LOG_SECURITY
125
+ end
126
+ if defined? Constants::LOG_SYSLOG
127
+ LOG_SYSLOG = Constants::LOG_SYSLOG
128
+ end
129
+ if defined? Constants::LOG_USER
130
+ LOG_USER = Constants::LOG_USER
131
+ end
132
+ if defined? Constants::LOG_UUCP
133
+ LOG_UUCP = Constants::LOG_UUCP
134
+ end
135
+ if defined? Constants::LOG_LOCAL0
136
+ LOG_LOCAL0 = Constants::LOG_LOCAL0
137
+ end
138
+ if defined? Constants::LOG_LOCAL1
139
+ LOG_LOCAL1 = Constants::LOG_LOCAL1
140
+ end
141
+ if defined? Constants::LOG_LOCAL2
142
+ LOG_LOCAL2 = Constants::LOG_LOCAL2
143
+ end
144
+ if defined? Constants::LOG_LOCAL3
145
+ LOG_LOCAL3 = Constants::LOG_LOCAL3
146
+ end
147
+ if defined? Constants::LOG_LOCAL4
148
+ LOG_LOCAL4 = Constants::LOG_LOCAL4
149
+ end
150
+ if defined? Constants::LOG_LOCAL5
151
+ LOG_LOCAL5 = Constants::LOG_LOCAL5
152
+ end
153
+ if defined? Constants::LOG_LOCAL6
154
+ LOG_LOCAL6 = Constants::LOG_LOCAL6
155
+ end
156
+ if defined? Constants::LOG_LOCAL7
157
+ LOG_LOCAL7 = Constants::LOG_LOCAL7
158
+ end
159
+ end
160
+
161
+ module Foreign
162
+ extend FFI::Library
163
+ ffi_lib FFI::Platform::LIBC
164
+
165
+ # methods
166
+ attach_function :open, "openlog", [:pointer, :int, :int], :void
167
+ attach_function :close, "closelog", [], :void
168
+ attach_function :write, "syslog", [:int, :string, :varargs], :void
169
+ attach_function :set_mask, "setlogmask", [:int], :int
170
+ end
171
+
172
+ class << self
173
+
174
+ ##
175
+ # returns the ident of the last open call
176
+ def ident
177
+ @opened ? @ident : nil
178
+ end
179
+
180
+ ##
181
+ # returns the options of the last open call
182
+ def options
183
+ @opened ? @options : nil
184
+ end
185
+
186
+ ##
187
+ # returns the facility of the last open call
188
+ def facility
189
+ @opened ? @facility : nil
190
+ end
191
+
192
+ ##
193
+ # mask
194
+ # mask=(mask)
195
+ #
196
+ # Returns or sets the log priority mask. The value of the mask
197
+ # is persistent and will not be reset by Syslog::open or
198
+ # Syslog::close.
199
+ #
200
+ # Example:
201
+ # Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR)
202
+ def mask
203
+ @mask ||= -1
204
+ @opened ? @mask : nil
205
+ end
206
+ attr_writer :mask
207
+
208
+ ##
209
+ # open(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS, facility = Syslog::LOG_USER) [{ |syslog| ... }]
210
+ #
211
+ # Opens syslog with the given options and returns the module
212
+ # itself. If a block is given, calls it with an argument of
213
+ # itself. If syslog is already opened, raises RuntimeError.
214
+ #
215
+ # Examples:
216
+ # Syslog.open('ftpd', Syslog::LOG_PID | Syslog::LOG_NDELAY, Syslog::LOG_FTP)
217
+ # open!(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS, facility = Syslog::LOG_USER)
218
+ # reopen(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS, facility = Syslog::LOG_USER)
219
+ def open(ident=nil, opt=nil, fac=nil)
220
+ raise "Syslog already open" unless not @opened
221
+
222
+ ident ||= $0
223
+ opt ||= Constants::LOG_PID | Constants::LOG_CONS
224
+ fac ||= Constants::LOG_USER
225
+
226
+ @ident = ident
227
+ @options = opt
228
+ @facility = fac
229
+ @ident_memory = if ident
230
+ FFI::MemoryPointer.from_string(ident)
231
+ else
232
+ nil
233
+ end
234
+ Foreign.open(@ident_memory, opt, fac)
235
+
236
+ @opened = true
237
+
238
+ # Calling set_mask twice is the standard way to set the 'default' mask
239
+ @mask = Foreign.set_mask(0)
240
+ Foreign.set_mask(@mask)
241
+
242
+ if block_given?
243
+ begin
244
+ yield self
245
+ ensure
246
+ close
247
+ end
248
+ end
249
+
250
+ self
251
+ end
252
+
253
+ ##
254
+ # like open, but closes it first
255
+ def reopen(*args, &block)
256
+ close
257
+ open(*args, &block)
258
+ end
259
+
260
+ alias_method :open!, :reopen
261
+
262
+ ##
263
+ # Is it open?
264
+ def opened?
265
+ @opened || false
266
+ end
267
+
268
+ ##
269
+ # Close the log
270
+ # close will raise an error if it is already closed
271
+ def close
272
+ raise "Syslog not opened" unless @opened
273
+
274
+ Foreign.close
275
+ @ident = nil
276
+ @options = @facility = @mask = -1;
277
+ @opened = false
278
+ end
279
+
280
+ ##
281
+ # log(Syslog::LOG_CRIT, "The %s is falling!", "sky")
282
+ #
283
+ # Doesn't take any platform specific printf statements
284
+ # logs things to $stderr
285
+ # log(Syslog::LOG_CRIT, "Welcome, %s, to my %s!", "leethaxxor", "lavratory")
286
+ def log(pri, *args)
287
+ write(pri, *args)
288
+ end
289
+
290
+ ##
291
+ # handy little shortcut for LOG_EMERG as the priority
292
+ def emerg(*args); write(Syslog::LOG_EMERG, *args); end
293
+
294
+ ##
295
+ # handy little shortcut for LOG_ALERT as the priority
296
+ def alert(*args); write(Syslog::LOG_ALERT, *args); end
297
+
298
+ ##
299
+ # handy little shortcut for LOG_ERR as the priority
300
+ def err(*args); write(Syslog::LOG_ERR, *args); end
301
+
302
+ ##
303
+ # handy little shortcut for LOG_CRIT as the priority
304
+ def crit(*args); write(Syslog::LOG_CRIT, *args); end
305
+
306
+ ##
307
+ # handy little shortcut for LOG_WARNING as the priority
308
+ def warning(*args);write(Syslog::LOG_WARNING, *args); end
309
+
310
+ ##
311
+ # handy little shortcut for LOG_NOTICE as the priority
312
+ def notice(*args); write(Syslog::LOG_NOTICE, *args); end
313
+
314
+ ##
315
+ # handy little shortcut for LOG_INFO as the priority
316
+ def info(*args); write(Syslog::LOG_INFO, *args); end
317
+
318
+ ##
319
+ # handy little shortcut for LOG_DEBUG as the priority
320
+ def debug(*args); write(Syslog::LOG_DEBUG, *args); end
321
+
322
+ ##
323
+ # LOG_MASK(pri)
324
+ #
325
+ # HACK copied from macro
326
+ # Creates a mask for one priority.
327
+ def LOG_MASK(pri)
328
+ 1 << pri
329
+ end
330
+
331
+ ##
332
+ # LOG_UPTO(pri)
333
+ # HACK copied from macro
334
+ # Creates a mask for all priorities up to pri.
335
+ def LOG_UPTO(pri)
336
+ (1 << ((pri)+1)) - 1
337
+ end
338
+
339
+ def inspect
340
+ if @opened
341
+ "<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>" %
342
+ [self.name, @ident, @options, @facility, @mask]
343
+ else
344
+ "<##{self.name}: opened=false>"
345
+ end
346
+ end
347
+
348
+ ##
349
+ # Syslog.instance # => Syslog
350
+ # Returns the Syslog module
351
+ def instance
352
+ self
353
+ end
354
+
355
+ FORMAT_STRING = '%s'
356
+ def write(pri, format, *args)
357
+ raise "Syslog must be opened before write" unless @opened
358
+
359
+ message = format % args
360
+ Foreign.write(pri, FORMAT_STRING, :string, message, :pointer, nil)
361
+ end
362
+ private :write
363
+ end
364
+ end
data/lib/syslog.rb CHANGED
@@ -1,10 +1,14 @@
1
1
  begin
2
- require 'syslog_ext'
2
+ if RUBY_ENGINE == 'jruby'
3
+ require 'syslog/jruby'
4
+ else
5
+ require 'syslog_ext'
6
+ end
3
7
  rescue LoadError
4
8
  raise LoadError.new(<<-EOS)
5
- Can't load Syslog!
6
-
7
- Syslog is not supported on your system. For Windows
8
- we recommend using the win32-eventlog gem.
9
- EOS
9
+ Can't load Syslog!
10
+
11
+ Syslog is not supported on your system. For Windows
12
+ we recommend using the win32-eventlog gem.
13
+ EOS
10
14
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syslog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akinori MUSHA
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-03-11 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: logger
@@ -35,6 +34,7 @@ files:
35
34
  - ".git-blame-ignore-revs"
36
35
  - ".github/CODEOWNERS"
37
36
  - ".github/dependabot.yml"
37
+ - ".github/release.yml"
38
38
  - ".github/workflows/push_gem.yml"
39
39
  - ".github/workflows/test.yml"
40
40
  - ".gitignore"
@@ -49,6 +49,7 @@ files:
49
49
  - ext/syslog/syslog.c
50
50
  - ext/syslog/syslog.txt
51
51
  - lib/syslog.rb
52
+ - lib/syslog/jruby.rb
52
53
  - lib/syslog/logger.rb
53
54
  - syslog.gemspec
54
55
  homepage: https://github.com/ruby/syslog
@@ -58,7 +59,6 @@ licenses:
58
59
  metadata:
59
60
  homepage_uri: https://github.com/ruby/syslog
60
61
  source_code_uri: https://github.com/ruby/syslog
61
- post_install_message:
62
62
  rdoc_options: []
63
63
  require_paths:
64
64
  - lib
@@ -73,8 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 3.5.11
77
- signing_key:
76
+ rubygems_version: 4.0.3
78
77
  specification_version: 4
79
78
  summary: Ruby interface for the POSIX system logging facility.
80
79
  test_files: []