apple-system-logger 0.1.2 → 0.2.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
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +9 -0
- data/Gemfile +2 -7
- data/README.md +7 -2
- data/Rakefile +14 -5
- data/apple-system-logger.gemspec +10 -7
- data/lib/apple/system/logger/constants.rb +11 -9
- data/lib/apple/system/logger/functions.rb +15 -13
- data/lib/apple/system/logger.rb +98 -71
- data/lib/apple-system-logger.rb +2 -0
- data/spec/apple-system-logger_spec.rb +41 -35
- data.tar.gz.sig +0 -0
- metadata +33 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 87eeec07795f0ea6b45a066e3178d8fe8a196c5157c862f2479b0fff701fd9c0
|
|
4
|
+
data.tar.gz: f474804c60c51890aaa6ab827f397ea5dc38478e24e0fd3bb11309ae736c0b28
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1e95379ce5810a866eea2d95cdf7aaa987a80ee4925d328c30400560f5d2580ed0222b8cf2b30a9bcfb76e04de89e14f44f22fb1baacd5e26f7153296999023
|
|
7
|
+
data.tar.gz: 6cb129e0da3705ef0f1fd22a3a572faf9412d4e6a666b05d633c1b06b531ac6c864e0b0ac06d169a4a181c7865b257f83cc8c59b9d69e87083d00c947e43d09e
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## 0.2.0 - 24-Jan-2026
|
|
2
|
+
* Make it thread safe.
|
|
3
|
+
|
|
4
|
+
## 0.1.3 - 28-Dec-2025
|
|
5
|
+
* Fixed the missing message parameter for the error and fatal methods.
|
|
6
|
+
* Added stricter enforcement for search keys.
|
|
7
|
+
* The constructor was modified internally for proper initialization.
|
|
8
|
+
* Some rubocop cleanup, spec updates, and workflow action tweaks.
|
|
9
|
+
|
|
1
10
|
## 0.1.2 - 28-Oct-2020
|
|
2
11
|
* Added the :stderr option.
|
|
3
12
|
* Added a Gemfile.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
[](https://github.com/djberg96/apple-system-logger/actions/workflows/ruby.yml)
|
|
2
|
+
|
|
1
3
|
## apple-system-logger
|
|
2
4
|
A Ruby interface for the Apple system logger.
|
|
3
5
|
|
|
4
6
|
## Installation
|
|
5
7
|
gem install apple-system-logger
|
|
6
8
|
|
|
9
|
+
## Adding the trusted cert
|
|
10
|
+
`gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/apple-system-logger/main/certs/djberg96_pub.pem)`
|
|
11
|
+
|
|
7
12
|
## Synopsis
|
|
8
|
-
```
|
|
13
|
+
```ruby
|
|
9
14
|
require 'apple-system-logger'
|
|
10
15
|
|
|
11
16
|
# With defaults
|
|
@@ -40,7 +45,7 @@ because the API does not explicitly forbid other file descriptors, nor
|
|
|
40
45
|
does it raise an error.
|
|
41
46
|
|
|
42
47
|
## Copyright
|
|
43
|
-
(C) 2020 Daniel J. Berger, All Rights Reserved
|
|
48
|
+
(C) 2020-2026 Daniel J. Berger, All Rights Reserved
|
|
44
49
|
|
|
45
50
|
## Warranty
|
|
46
51
|
This package is provided "as is" and without any express or
|
data/Rakefile
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
require 'rake'
|
|
2
2
|
require 'rake/clean'
|
|
3
|
-
require 'rbconfig'
|
|
4
3
|
require 'rspec/core/rake_task'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
4
|
+
require 'rubocop/rake_task'
|
|
8
5
|
|
|
9
6
|
CLEAN.include('**/*.gem', '**/*.rbc', '**/*.rbx', '**/*.lock')
|
|
10
7
|
|
|
@@ -12,7 +9,7 @@ namespace 'gem' do
|
|
|
12
9
|
desc "Create the apple-system-logger gem"
|
|
13
10
|
task :create => [:clean] do
|
|
14
11
|
require 'rubygems/package'
|
|
15
|
-
spec =
|
|
12
|
+
spec = Gem::Specification.load('apple-system-logger.gemspec')
|
|
16
13
|
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
|
17
14
|
Gem::Package.build(spec)
|
|
18
15
|
end
|
|
@@ -24,4 +21,16 @@ namespace 'gem' do
|
|
|
24
21
|
end
|
|
25
22
|
end
|
|
26
23
|
|
|
24
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
25
|
+
t.verbose = true
|
|
26
|
+
t.rspec_opts = '-f documentation -w'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
RuboCop::RakeTask.new
|
|
30
|
+
|
|
31
|
+
# Clean up afterwards
|
|
32
|
+
Rake::Task[:spec].enhance do
|
|
33
|
+
Rake::Task[:clean].invoke
|
|
34
|
+
end
|
|
35
|
+
|
|
27
36
|
task :default => :spec
|
data/apple-system-logger.gemspec
CHANGED
|
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = 'apple-system-logger'
|
|
5
|
-
spec.version = '0.
|
|
5
|
+
spec.version = '0.2.0'
|
|
6
6
|
spec.author = 'Daniel J. Berger'
|
|
7
7
|
spec.email = 'djberg96@gmail.com'
|
|
8
8
|
spec.license = 'Apache-2.0'
|
|
@@ -15,14 +15,17 @@ Gem::Specification.new do |spec|
|
|
|
15
15
|
spec.add_dependency('ffi', '~> 1.1')
|
|
16
16
|
spec.add_development_dependency('rake')
|
|
17
17
|
spec.add_development_dependency('rspec', '~> 3.9')
|
|
18
|
+
spec.add_development_dependency('rubocop')
|
|
19
|
+
spec.add_development_dependency('rubocop-rspec')
|
|
18
20
|
|
|
19
21
|
spec.metadata = {
|
|
20
|
-
'homepage_uri'
|
|
21
|
-
'bug_tracker_uri'
|
|
22
|
-
'changelog_uri'
|
|
23
|
-
'documentation_uri'
|
|
24
|
-
'source_code_uri'
|
|
25
|
-
'wiki_uri'
|
|
22
|
+
'homepage_uri' => 'https://github.com/djberg96/apple-system-logger',
|
|
23
|
+
'bug_tracker_uri' => 'https://github.com/djberg96/apple-system-logger/issues',
|
|
24
|
+
'changelog_uri' => 'https://github.com/djberg96/apple-system-logger/blob/main/CHANGES.md',
|
|
25
|
+
'documentation_uri' => 'https://github.com/djberg96/apple-system-logger/wiki',
|
|
26
|
+
'source_code_uri' => 'https://github.com/djberg96/apple-system-logger',
|
|
27
|
+
'wiki_uri' => 'https://github.com/djberg96/apple-system-logger/wiki',
|
|
28
|
+
'rubygems_mfa_required' => 'true'
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
spec.description = <<-EOF
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Apple
|
|
2
4
|
module System
|
|
3
5
|
module LoggerConstants
|
|
4
|
-
ASL_KEY_TIME =
|
|
5
|
-
ASL_KEY_HOST =
|
|
6
|
-
ASL_KEY_SENDER =
|
|
7
|
-
ASL_KEY_FACILITY =
|
|
8
|
-
ASL_KEY_PID =
|
|
9
|
-
ASL_KEY_UID =
|
|
10
|
-
ASL_KEY_GID =
|
|
11
|
-
ASL_KEY_LEVEL =
|
|
12
|
-
ASL_KEY_MSG =
|
|
6
|
+
ASL_KEY_TIME = 'Time'
|
|
7
|
+
ASL_KEY_HOST = 'Host'
|
|
8
|
+
ASL_KEY_SENDER = 'Sender'
|
|
9
|
+
ASL_KEY_FACILITY = 'Facility'
|
|
10
|
+
ASL_KEY_PID = 'PID'
|
|
11
|
+
ASL_KEY_UID = 'UID'
|
|
12
|
+
ASL_KEY_GID = 'GID'
|
|
13
|
+
ASL_KEY_LEVEL = 'Level'
|
|
14
|
+
ASL_KEY_MSG = 'Message'
|
|
13
15
|
|
|
14
16
|
ASL_LEVEL_EMERG = 0
|
|
15
17
|
ASL_LEVEL_ALERT = 1
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'ffi'
|
|
2
4
|
|
|
3
5
|
module Apple
|
|
@@ -6,22 +8,22 @@ module Apple
|
|
|
6
8
|
extend FFI::Library
|
|
7
9
|
ffi_lib FFI::Library::LIBC
|
|
8
10
|
|
|
9
|
-
attach_function(:asl_add_log_file, [
|
|
11
|
+
attach_function(:asl_add_log_file, %i[pointer int], :int)
|
|
10
12
|
attach_function(:asl_close, [:pointer], :void)
|
|
11
13
|
attach_function(:asl_free, [:pointer], :void)
|
|
12
|
-
attach_function(:asl_get, [
|
|
13
|
-
attach_function(:asl_key, [
|
|
14
|
-
attach_function(:asl_log, [
|
|
14
|
+
attach_function(:asl_get, %i[pointer string], :string)
|
|
15
|
+
attach_function(:asl_key, %i[pointer uint32], :string)
|
|
16
|
+
attach_function(:asl_log, %i[pointer pointer int string varargs], :int)
|
|
15
17
|
attach_function(:asl_new, [:uint32], :pointer)
|
|
16
|
-
attach_function(:asl_open, [
|
|
17
|
-
attach_function(:asl_remove_log_file, [
|
|
18
|
-
attach_function(:asl_search, [
|
|
19
|
-
attach_function(:asl_send, [
|
|
20
|
-
attach_function(:asl_set, [
|
|
21
|
-
attach_function(:asl_set_filter, [
|
|
22
|
-
attach_function(:asl_set_query, [
|
|
23
|
-
attach_function(:asl_unset, [
|
|
24
|
-
attach_function(:asl_vlog, [
|
|
18
|
+
attach_function(:asl_open, %i[string string uint32], :pointer)
|
|
19
|
+
attach_function(:asl_remove_log_file, %i[pointer int], :int)
|
|
20
|
+
attach_function(:asl_search, %i[pointer pointer], :pointer)
|
|
21
|
+
attach_function(:asl_send, %i[pointer pointer], :int)
|
|
22
|
+
attach_function(:asl_set, %i[pointer string string], :int)
|
|
23
|
+
attach_function(:asl_set_filter, %i[pointer int], :int)
|
|
24
|
+
attach_function(:asl_set_query, %i[pointer string string uint32], :int)
|
|
25
|
+
attach_function(:asl_unset, %i[pointer string], :int)
|
|
26
|
+
attach_function(:asl_vlog, %i[pointer pointer int string pointer], :int)
|
|
25
27
|
attach_function(:aslresponse_free, [:pointer], :void)
|
|
26
28
|
attach_function(:aslresponse_next, [:pointer], :pointer)
|
|
27
29
|
end
|
data/lib/apple/system/logger.rb
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require_relative 'logger/functions'
|
|
2
4
|
require_relative 'logger/constants'
|
|
5
|
+
require 'thread'
|
|
3
6
|
|
|
7
|
+
# The Apple module serves as a namespace only.
|
|
4
8
|
module Apple
|
|
9
|
+
# The System module serves only as a namespace.
|
|
5
10
|
module System
|
|
11
|
+
# The Logger class encapsulates the logging functions of the OSX logging API.
|
|
6
12
|
class Logger
|
|
7
13
|
include Apple::System::LoggerFunctions
|
|
8
14
|
include Apple::System::LoggerConstants
|
|
9
15
|
|
|
10
16
|
# The version of this library.
|
|
11
|
-
VERSION = '0.
|
|
17
|
+
VERSION = '0.2.0'
|
|
12
18
|
|
|
13
19
|
# A syslogd facility. The system default is 'user'.
|
|
14
20
|
attr_reader :facility
|
|
@@ -63,24 +69,20 @@ module Apple
|
|
|
63
69
|
# TODO: Add string format support and apply it to messages.
|
|
64
70
|
#
|
|
65
71
|
def initialize(**kwargs)
|
|
72
|
+
@mutex = Mutex.new
|
|
73
|
+
|
|
66
74
|
@facility = kwargs[:facility]
|
|
67
75
|
@level = kwargs[:level] || ASL_LEVEL_DEBUG
|
|
68
76
|
@progname = kwargs[:progname]
|
|
69
77
|
@logdev = kwargs[:logdev]
|
|
70
78
|
@stderr = kwargs[:stderr]
|
|
71
79
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
options |= ASL_OPT_STDERR if @stderr
|
|
80
|
+
options = ASL_OPT_NO_DELAY | ASL_OPT_NO_REMOTE
|
|
81
|
+
options |= ASL_OPT_STDERR if @stderr
|
|
75
82
|
|
|
76
|
-
|
|
83
|
+
@aslclient = asl_open(@progname, @facility, options)
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
asl_add_log_file(@aslclient, @logdev.fileno)
|
|
80
|
-
end
|
|
81
|
-
else
|
|
82
|
-
@aslclient = nil
|
|
83
|
-
end
|
|
85
|
+
asl_add_log_file(@aslclient, @logdev.fileno) if @logdev
|
|
84
86
|
|
|
85
87
|
@aslmsg = asl_new(ASL_TYPE_MSG)
|
|
86
88
|
asl_set(@aslmsg, ASL_KEY_FACILITY, @facility) if @facility
|
|
@@ -98,19 +100,25 @@ module Apple
|
|
|
98
100
|
# Dump a message with no formatting at the current severity level.
|
|
99
101
|
#
|
|
100
102
|
def <<(message)
|
|
101
|
-
|
|
103
|
+
@mutex.synchronize do
|
|
104
|
+
asl_log(@aslclient, @aslmsg, @level, message)
|
|
105
|
+
end
|
|
102
106
|
end
|
|
103
107
|
|
|
104
108
|
# Log a message at the given level.
|
|
105
109
|
#
|
|
106
110
|
def add(level, message)
|
|
107
|
-
|
|
111
|
+
@mutex.synchronize do
|
|
112
|
+
asl_log(@aslclient, @aslmsg, level, message)
|
|
113
|
+
end
|
|
108
114
|
end
|
|
109
115
|
|
|
110
116
|
# Log a debug message.
|
|
111
117
|
#
|
|
112
118
|
def debug(message)
|
|
113
|
-
|
|
119
|
+
@mutex.synchronize do
|
|
120
|
+
asl_log(@aslclient, @aslmsg, ASL_LEVEL_DEBUG, message)
|
|
121
|
+
end
|
|
114
122
|
end
|
|
115
123
|
|
|
116
124
|
# Returns true if the current severity level allows for the printing of debug messages.
|
|
@@ -122,7 +130,9 @@ module Apple
|
|
|
122
130
|
# Log an info message.
|
|
123
131
|
#
|
|
124
132
|
def info(message)
|
|
125
|
-
|
|
133
|
+
@mutex.synchronize do
|
|
134
|
+
asl_log(@aslclient, @aslmsg, ASL_LEVEL_INFO, message)
|
|
135
|
+
end
|
|
126
136
|
end
|
|
127
137
|
|
|
128
138
|
# Returns true if the current severity level allows for the printing of info messages.
|
|
@@ -134,7 +144,9 @@ module Apple
|
|
|
134
144
|
# Log a warning message.
|
|
135
145
|
#
|
|
136
146
|
def warn(message)
|
|
137
|
-
|
|
147
|
+
@mutex.synchronize do
|
|
148
|
+
asl_log(@aslclient, @aslmsg, ASL_LEVEL_WARNING, message)
|
|
149
|
+
end
|
|
138
150
|
end
|
|
139
151
|
|
|
140
152
|
# Returns true if the current severity level allows for the printing of warning messages.
|
|
@@ -145,11 +157,13 @@ module Apple
|
|
|
145
157
|
|
|
146
158
|
# Log an error message.
|
|
147
159
|
#
|
|
148
|
-
def error
|
|
149
|
-
|
|
160
|
+
def error(message)
|
|
161
|
+
@mutex.synchronize do
|
|
162
|
+
asl_log(@aslclient, @aslmsg, ASL_LEVEL_ERR, message)
|
|
163
|
+
end
|
|
150
164
|
end
|
|
151
165
|
|
|
152
|
-
# Returns true if the current severity level allows for the printing of
|
|
166
|
+
# Returns true if the current severity level allows for the printing of error messages.
|
|
153
167
|
#
|
|
154
168
|
def error?
|
|
155
169
|
level >= ASL_LEVEL_ERR
|
|
@@ -157,8 +171,10 @@ module Apple
|
|
|
157
171
|
|
|
158
172
|
# Log a fatal message. For this library that means an ASL_LEVEL_CRIT message.
|
|
159
173
|
#
|
|
160
|
-
def fatal
|
|
161
|
-
|
|
174
|
+
def fatal(message)
|
|
175
|
+
@mutex.synchronize do
|
|
176
|
+
asl_log(@aslclient, @aslmsg, ASL_LEVEL_CRIT, message)
|
|
177
|
+
end
|
|
162
178
|
end
|
|
163
179
|
|
|
164
180
|
# Returns true if the current severity level allows for the printing of fatal messages.
|
|
@@ -170,7 +186,9 @@ module Apple
|
|
|
170
186
|
# Log an unknown message. For this library that means an ASL_LEVEL_EMERG message.
|
|
171
187
|
#
|
|
172
188
|
def unknown(message)
|
|
173
|
-
|
|
189
|
+
@mutex.synchronize do
|
|
190
|
+
asl_log(@aslclient, @aslmsg, ASL_LEVEL_EMERG, message)
|
|
191
|
+
end
|
|
174
192
|
end
|
|
175
193
|
|
|
176
194
|
# Search the logs using the provided query. The query should be a hash of
|
|
@@ -224,73 +242,82 @@ module Apple
|
|
|
224
242
|
# log.search(:uid => 501, :time => Time.now - 3600)
|
|
225
243
|
#
|
|
226
244
|
def search(query)
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
flags = (flags | ASL_QUERY_OP_GREATER_EQUAL)
|
|
239
|
-
value = value.to_i
|
|
240
|
-
end
|
|
245
|
+
@mutex.synchronize do
|
|
246
|
+
result = []
|
|
247
|
+
|
|
248
|
+
aslmsg = asl_new(ASL_TYPE_QUERY)
|
|
249
|
+
|
|
250
|
+
query.each do |key, value|
|
|
251
|
+
asl_key = map_key_to_asl_key(key)
|
|
252
|
+
|
|
253
|
+
flags = ASL_QUERY_OP_EQUAL
|
|
254
|
+
flags = (flags | ASL_QUERY_OP_NUMERIC) if value.is_a?(Numeric)
|
|
255
|
+
flags = (flags | ASL_QUERY_OP_TRUE) if value == true
|
|
241
256
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
257
|
+
if value.is_a?(Time)
|
|
258
|
+
flags = (flags | ASL_QUERY_OP_GREATER_EQUAL)
|
|
259
|
+
value = value.to_i
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
if value.is_a?(Regexp)
|
|
263
|
+
flags = (flags | ASL_QUERY_OP_REGEX)
|
|
264
|
+
flags = (flags | ASL_QUERY_OP_CASEFOLD) if value.casefold?
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
asl_set_query(aslmsg, asl_key, value.to_s, flags)
|
|
245
268
|
end
|
|
246
269
|
|
|
247
|
-
|
|
248
|
-
end
|
|
270
|
+
response = asl_search(@aslclient, aslmsg)
|
|
249
271
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
272
|
+
if response.nil?
|
|
273
|
+
raise RuntimeError, "asl_search function call failed"
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
while m = aslresponse_next(response)
|
|
277
|
+
break if m.null?
|
|
278
|
+
i = 0
|
|
279
|
+
hash = {}
|
|
280
|
+
while key = asl_key(m, i)
|
|
281
|
+
break if key.nil? || key.empty?
|
|
282
|
+
value = asl_get(m, key)
|
|
283
|
+
hash[key] = value
|
|
284
|
+
i += 1
|
|
285
|
+
end
|
|
286
|
+
result << hash
|
|
261
287
|
end
|
|
262
|
-
result << hash
|
|
263
|
-
end
|
|
264
288
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
289
|
+
result
|
|
290
|
+
ensure
|
|
291
|
+
aslresponse_free(response) if response
|
|
292
|
+
asl_free(aslmsg)
|
|
293
|
+
end
|
|
269
294
|
end
|
|
270
295
|
|
|
271
296
|
# Close the logger instance. You should always do this.
|
|
272
297
|
#
|
|
273
298
|
def close
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
299
|
+
@mutex.synchronize do
|
|
300
|
+
asl_free(@aslmsg) if @aslmsg
|
|
301
|
+
asl_close(@aslclient) if @aslclient
|
|
302
|
+
@aslmsg = nil
|
|
303
|
+
@aslclient = nil
|
|
304
|
+
end
|
|
278
305
|
end
|
|
279
306
|
|
|
280
307
|
private
|
|
281
308
|
|
|
282
309
|
def map_key_to_asl_key(key)
|
|
283
310
|
{
|
|
284
|
-
:time
|
|
285
|
-
:host
|
|
286
|
-
:sender
|
|
311
|
+
:time => ASL_KEY_TIME,
|
|
312
|
+
:host => ASL_KEY_HOST,
|
|
313
|
+
:sender => ASL_KEY_SENDER,
|
|
287
314
|
:facility => ASL_KEY_FACILITY,
|
|
288
|
-
:pid
|
|
289
|
-
:uid
|
|
290
|
-
:gid
|
|
291
|
-
:level
|
|
292
|
-
:message
|
|
293
|
-
}
|
|
315
|
+
:pid => ASL_KEY_PID,
|
|
316
|
+
:uid => ASL_KEY_UID,
|
|
317
|
+
:gid => ASL_KEY_GID,
|
|
318
|
+
:level => ASL_KEY_LEVEL,
|
|
319
|
+
:message => ASL_KEY_MSG
|
|
320
|
+
}.fetch(key)
|
|
294
321
|
end
|
|
295
322
|
end
|
|
296
323
|
end
|
data/lib/apple-system-logger.rb
CHANGED
|
@@ -1,125 +1,131 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'apple-system-logger'
|
|
2
4
|
|
|
3
5
|
RSpec.describe Apple::System::Logger do
|
|
4
6
|
let(:log){ described_class.new }
|
|
5
7
|
|
|
6
|
-
context
|
|
7
|
-
example
|
|
8
|
-
expect(described_class::VERSION).to eql('0.
|
|
8
|
+
context 'version' do
|
|
9
|
+
example 'version constant is set to expected value' do
|
|
10
|
+
expect(described_class::VERSION).to eql('0.2.0')
|
|
9
11
|
end
|
|
10
12
|
|
|
11
|
-
example
|
|
13
|
+
example 'version constant is frozen' do
|
|
12
14
|
expect(described_class::VERSION).to be_frozen
|
|
13
15
|
end
|
|
14
16
|
end
|
|
15
17
|
|
|
16
|
-
context
|
|
17
|
-
example
|
|
18
|
+
context 'instance methods' do
|
|
19
|
+
example 'defines a facility method' do
|
|
18
20
|
expect(log).to respond_to(:facility)
|
|
19
21
|
end
|
|
20
22
|
|
|
21
|
-
example
|
|
23
|
+
example 'the default facility is nil' do
|
|
22
24
|
expect(log.facility).to be_nil
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
example
|
|
27
|
+
example 'defines a level method' do
|
|
26
28
|
expect(log).to respond_to(:level)
|
|
27
29
|
end
|
|
28
30
|
|
|
29
|
-
example
|
|
31
|
+
example 'the default level is debug' do
|
|
30
32
|
expect(log.level).to eql(Apple::System::Logger::ASL_LEVEL_DEBUG)
|
|
31
33
|
end
|
|
32
34
|
|
|
33
|
-
example
|
|
35
|
+
example 'defines a progname method' do
|
|
34
36
|
expect(log).to respond_to(:progname)
|
|
35
37
|
end
|
|
36
38
|
|
|
37
|
-
example
|
|
39
|
+
example 'the default progname is nil' do
|
|
38
40
|
expect(log.progname).to be_nil
|
|
39
41
|
end
|
|
40
42
|
|
|
41
|
-
example
|
|
43
|
+
example 'defines a logdev method' do
|
|
42
44
|
expect(log).to respond_to(:logdev)
|
|
43
45
|
end
|
|
44
46
|
|
|
45
|
-
example
|
|
47
|
+
example 'the default logdev is nil' do
|
|
46
48
|
expect(log.logdev).to be_nil
|
|
47
49
|
end
|
|
48
50
|
end
|
|
49
51
|
|
|
50
|
-
context
|
|
51
|
-
example
|
|
52
|
+
context 'logging methods' do
|
|
53
|
+
example 'there is a << method' do
|
|
52
54
|
expect(log).to respond_to(:<<)
|
|
53
55
|
end
|
|
54
56
|
|
|
55
|
-
example
|
|
57
|
+
example 'there is an add method' do
|
|
56
58
|
expect(log).to respond_to(:add)
|
|
57
59
|
end
|
|
58
60
|
|
|
59
|
-
example
|
|
61
|
+
example 'there is a debug method' do
|
|
60
62
|
expect(log).to respond_to(:debug)
|
|
61
63
|
end
|
|
62
64
|
|
|
63
|
-
example
|
|
65
|
+
example 'there is a debug? method that returns the expected value' do
|
|
64
66
|
expect(log.debug?).to be true
|
|
65
67
|
end
|
|
66
68
|
|
|
67
|
-
example
|
|
69
|
+
example 'there is an info method' do
|
|
68
70
|
expect(log).to respond_to(:info)
|
|
69
71
|
end
|
|
70
72
|
|
|
71
|
-
example
|
|
73
|
+
example 'there is a info? method that returns the expected value' do
|
|
72
74
|
expect(log.info?).to be true
|
|
73
75
|
end
|
|
74
76
|
|
|
75
|
-
example
|
|
77
|
+
example 'there is a warn method' do
|
|
76
78
|
expect(log).to respond_to(:warn)
|
|
77
79
|
end
|
|
78
80
|
|
|
79
|
-
example
|
|
81
|
+
example 'there is a warn? method that returns the expected value' do
|
|
80
82
|
expect(log.warn?).to be true
|
|
81
83
|
end
|
|
82
84
|
|
|
83
|
-
example
|
|
85
|
+
example 'there is an error method' do
|
|
84
86
|
expect(log).to respond_to(:error)
|
|
85
87
|
end
|
|
86
88
|
|
|
87
|
-
example
|
|
89
|
+
example 'there is a error? method that returns the expected value' do
|
|
88
90
|
expect(log.error?).to be true
|
|
89
91
|
end
|
|
90
92
|
|
|
91
|
-
example
|
|
92
|
-
expect(log).to respond_to(:
|
|
93
|
+
example 'there is a fatal method' do
|
|
94
|
+
expect(log).to respond_to(:fatal)
|
|
93
95
|
end
|
|
94
96
|
|
|
95
|
-
example
|
|
97
|
+
example 'there is a fatal? method that returns the expected value' do
|
|
96
98
|
expect(log.fatal?).to be true
|
|
97
99
|
end
|
|
98
100
|
|
|
99
|
-
example
|
|
101
|
+
example 'there is an unknown method' do
|
|
100
102
|
expect(log).to respond_to(:unknown)
|
|
101
103
|
end
|
|
102
104
|
|
|
103
|
-
example
|
|
105
|
+
example 'there is a close method' do
|
|
104
106
|
expect(log).to respond_to(:close)
|
|
105
107
|
end
|
|
106
108
|
|
|
107
|
-
example
|
|
109
|
+
example 'calling close on the logger instance works as expected' do
|
|
108
110
|
expect(log.close).to be_nil
|
|
109
111
|
expect(log.close).to be_nil
|
|
110
112
|
end
|
|
111
113
|
end
|
|
112
114
|
|
|
113
|
-
context
|
|
114
|
-
example
|
|
115
|
+
context 'search' do
|
|
116
|
+
example 'there is a search method' do
|
|
115
117
|
expect(log).to respond_to(:search)
|
|
116
118
|
end
|
|
117
119
|
|
|
118
|
-
example
|
|
120
|
+
example 'a basic search returns the expected results' do
|
|
119
121
|
result = log.search(:sender => 'bootlog', :level => 5)
|
|
120
|
-
expect(result).to
|
|
121
|
-
expect(result.first).to
|
|
122
|
+
expect(result).to be_a(Array)
|
|
123
|
+
expect(result.first).to be_a(Hash)
|
|
122
124
|
expect(result.size).to be >= 1
|
|
123
125
|
end
|
|
126
|
+
|
|
127
|
+
example 'search keys must be valid' do
|
|
128
|
+
expect{ log.search(:bogus => 'bootlog') }.to raise_error(KeyError)
|
|
129
|
+
end
|
|
124
130
|
end
|
|
125
131
|
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: apple-system-logger
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel J. Berger
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain:
|
|
11
10
|
- |
|
|
@@ -35,7 +34,7 @@ cert_chain:
|
|
|
35
34
|
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
|
36
35
|
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
|
37
36
|
-----END CERTIFICATE-----
|
|
38
|
-
date:
|
|
37
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
39
38
|
dependencies:
|
|
40
39
|
- !ruby/object:Gem::Dependency
|
|
41
40
|
name: ffi
|
|
@@ -79,6 +78,34 @@ dependencies:
|
|
|
79
78
|
- - "~>"
|
|
80
79
|
- !ruby/object:Gem::Version
|
|
81
80
|
version: '3.9'
|
|
81
|
+
- !ruby/object:Gem::Dependency
|
|
82
|
+
name: rubocop
|
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '0'
|
|
88
|
+
type: :development
|
|
89
|
+
prerelease: false
|
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
- !ruby/object:Gem::Dependency
|
|
96
|
+
name: rubocop-rspec
|
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - ">="
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '0'
|
|
102
|
+
type: :development
|
|
103
|
+
prerelease: false
|
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
+
requirements:
|
|
106
|
+
- - ">="
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '0'
|
|
82
109
|
description: " The apple-system-logger library provides an interface for the Apple
|
|
83
110
|
System\n Library. You can both write to, and search, your mac's system logs using\n
|
|
84
111
|
\ this library using an API that is very similar to the stdlib Logger interface.
|
|
@@ -107,11 +134,11 @@ licenses:
|
|
|
107
134
|
metadata:
|
|
108
135
|
homepage_uri: https://github.com/djberg96/apple-system-logger
|
|
109
136
|
bug_tracker_uri: https://github.com/djberg96/apple-system-logger/issues
|
|
110
|
-
changelog_uri: https://github.com/djberg96/apple-system-logger/blob/
|
|
137
|
+
changelog_uri: https://github.com/djberg96/apple-system-logger/blob/main/CHANGES.md
|
|
111
138
|
documentation_uri: https://github.com/djberg96/apple-system-logger/wiki
|
|
112
139
|
source_code_uri: https://github.com/djberg96/apple-system-logger
|
|
113
140
|
wiki_uri: https://github.com/djberg96/apple-system-logger/wiki
|
|
114
|
-
|
|
141
|
+
rubygems_mfa_required: 'true'
|
|
115
142
|
rdoc_options: []
|
|
116
143
|
require_paths:
|
|
117
144
|
- lib
|
|
@@ -126,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
126
153
|
- !ruby/object:Gem::Version
|
|
127
154
|
version: '0'
|
|
128
155
|
requirements: []
|
|
129
|
-
rubygems_version:
|
|
130
|
-
signing_key:
|
|
156
|
+
rubygems_version: 4.0.3
|
|
131
157
|
specification_version: 4
|
|
132
158
|
summary: A Ruby interface for the Apple System Logger
|
|
133
159
|
test_files:
|
metadata.gz.sig
CHANGED
|
Binary file
|