syslog 0.2.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 +4 -4
- data/.github/release.yml +4 -0
- data/.github/workflows/push_gem.yml +5 -5
- data/.github/workflows/test.yml +14 -4
- data/{LICENSE.txt → BSDL} +3 -3
- data/COPYING +56 -0
- data/Rakefile +13 -7
- data/ext/syslog/extconf.rb +2 -2
- data/ext/syslog/syslog.c +1 -1
- data/lib/syslog/jruby.rb +364 -0
- data/lib/syslog.rb +10 -6
- data/syslog.gemspec +2 -0
- metadata +22 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83c32c413293d9c1902db61758c3f53403e5e0f1218a8ec8fa1477eb63413559
|
|
4
|
+
data.tar.gz: 49df9dd2ac69c88ebd80c2b3d572066c65382295e791ad688aa30eb758667e02
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ca7483657ae6615cffeedd4fbf9641863eae3ac1e7f1f2cfddf3a634fc99c16e0dc8661d72c247e359654e56108c6b907465e97a76e653b328f2a42c307b06aa
|
|
7
|
+
data.tar.gz: 3df3ce9c54557473f754e57f7792419ca2c9b52301b8c8cd14a786238de2a052a448ae9de4f9b6b8dc10bd1d1bdc38ffde9611a3612a76f87e8663c3671e9304
|
data/.github/release.yml
ADDED
|
@@ -23,24 +23,24 @@ jobs:
|
|
|
23
23
|
|
|
24
24
|
steps:
|
|
25
25
|
- name: Harden Runner
|
|
26
|
-
uses: step-security/harden-runner@
|
|
26
|
+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
|
27
27
|
with:
|
|
28
28
|
egress-policy: audit
|
|
29
29
|
|
|
30
|
-
- uses: actions/checkout@
|
|
30
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
31
31
|
|
|
32
32
|
- name: Set up Ruby
|
|
33
|
-
uses: ruby/setup-ruby@
|
|
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@
|
|
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.
|
|
46
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
data/.github/workflows/test.yml
CHANGED
|
@@ -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:
|
|
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-
|
|
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@
|
|
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/{LICENSE.txt → BSDL}
RENAMED
|
@@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without
|
|
|
4
4
|
modification, are permitted provided that the following conditions
|
|
5
5
|
are met:
|
|
6
6
|
1. Redistributions of source code must retain the above copyright
|
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
|
8
8
|
2. Redistributions in binary form must reproduce the above copyright
|
|
9
|
-
notice, this list of conditions and the following disclaimer in the
|
|
10
|
-
documentation and/or other materials provided with the distribution.
|
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
|
10
|
+
documentation and/or other materials provided with the distribution.
|
|
11
11
|
|
|
12
12
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
13
13
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
data/COPYING
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
|
4
|
+
|
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
|
6
|
+
software without restriction, provided that you duplicate all of the
|
|
7
|
+
original copyright notices and associated disclaimers.
|
|
8
|
+
|
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
|
10
|
+
you do at least ONE of the following:
|
|
11
|
+
|
|
12
|
+
a. place your modifications in the Public Domain or otherwise
|
|
13
|
+
make them Freely Available, such as by posting said
|
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
|
15
|
+
the author to include your modifications in the software.
|
|
16
|
+
|
|
17
|
+
b. use the modified software only within your corporation or
|
|
18
|
+
organization.
|
|
19
|
+
|
|
20
|
+
c. give non-standard binaries non-standard names, with
|
|
21
|
+
instructions on where to get the original software distribution.
|
|
22
|
+
|
|
23
|
+
d. make other distribution arrangements with the author.
|
|
24
|
+
|
|
25
|
+
3. You may distribute the software in object code or binary form,
|
|
26
|
+
provided that you do at least ONE of the following:
|
|
27
|
+
|
|
28
|
+
a. distribute the binaries and library files of the software,
|
|
29
|
+
together with instructions (in the manual page or equivalent)
|
|
30
|
+
on where to get the original distribution.
|
|
31
|
+
|
|
32
|
+
b. accompany the distribution with the machine-readable source of
|
|
33
|
+
the software.
|
|
34
|
+
|
|
35
|
+
c. give non-standard binaries non-standard names, with
|
|
36
|
+
instructions on where to get the original software distribution.
|
|
37
|
+
|
|
38
|
+
d. make other distribution arrangements with the author.
|
|
39
|
+
|
|
40
|
+
4. You may modify and include the part of the software into any other
|
|
41
|
+
software (possibly commercial). But some files in the distribution
|
|
42
|
+
are not written by the author, so that they are not under these terms.
|
|
43
|
+
|
|
44
|
+
For the list of those files and their copying conditions, see the
|
|
45
|
+
file LEGAL.
|
|
46
|
+
|
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
|
48
|
+
output from the software do not automatically fall under the
|
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
|
51
|
+
software.
|
|
52
|
+
|
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
56
|
+
PURPOSE.
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
data/ext/syslog/extconf.rb
CHANGED
|
@@ -11,10 +11,10 @@ def generate_dummy_makefile
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def windows?
|
|
14
|
-
RbConfig::CONFIG["host_os"] =~ /mswin|mingw
|
|
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
data/lib/syslog/jruby.rb
ADDED
|
@@ -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
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
data/syslog.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: syslog
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 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:
|
|
12
|
-
dependencies:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: logger
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
13
26
|
description: Ruby interface for the POSIX system logging facility.
|
|
14
27
|
email:
|
|
15
28
|
- knu@idaemons.org
|
|
@@ -21,11 +34,13 @@ files:
|
|
|
21
34
|
- ".git-blame-ignore-revs"
|
|
22
35
|
- ".github/CODEOWNERS"
|
|
23
36
|
- ".github/dependabot.yml"
|
|
37
|
+
- ".github/release.yml"
|
|
24
38
|
- ".github/workflows/push_gem.yml"
|
|
25
39
|
- ".github/workflows/test.yml"
|
|
26
40
|
- ".gitignore"
|
|
41
|
+
- BSDL
|
|
42
|
+
- COPYING
|
|
27
43
|
- Gemfile
|
|
28
|
-
- LICENSE.txt
|
|
29
44
|
- README.md
|
|
30
45
|
- Rakefile
|
|
31
46
|
- bin/console
|
|
@@ -34,6 +49,7 @@ files:
|
|
|
34
49
|
- ext/syslog/syslog.c
|
|
35
50
|
- ext/syslog/syslog.txt
|
|
36
51
|
- lib/syslog.rb
|
|
52
|
+
- lib/syslog/jruby.rb
|
|
37
53
|
- lib/syslog/logger.rb
|
|
38
54
|
- syslog.gemspec
|
|
39
55
|
homepage: https://github.com/ruby/syslog
|
|
@@ -43,7 +59,6 @@ licenses:
|
|
|
43
59
|
metadata:
|
|
44
60
|
homepage_uri: https://github.com/ruby/syslog
|
|
45
61
|
source_code_uri: https://github.com/ruby/syslog
|
|
46
|
-
post_install_message:
|
|
47
62
|
rdoc_options: []
|
|
48
63
|
require_paths:
|
|
49
64
|
- lib
|
|
@@ -58,8 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
58
73
|
- !ruby/object:Gem::Version
|
|
59
74
|
version: '0'
|
|
60
75
|
requirements: []
|
|
61
|
-
rubygems_version:
|
|
62
|
-
signing_key:
|
|
76
|
+
rubygems_version: 4.0.3
|
|
63
77
|
specification_version: 4
|
|
64
78
|
summary: Ruby interface for the POSIX system logging facility.
|
|
65
79
|
test_files: []
|