oslg 0.2.2 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/pull_request.yml +2 -2
- data/README.md +42 -38
- data/Rakefile +0 -5
- data/lib/oslg/oslog.rb +97 -80
- data/lib/oslg/version.rb +1 -1
- data/oslg.gemspec +5 -3
- metadata +5 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 398d4fc89206f836beea1d95578ef91629243c4f037ab9ac304359c16843e6ab
|
4
|
+
data.tar.gz: dcfb0a23e252ac13a396fda86117d7ae04aa087e9e4ec740c5efb93f2637b701
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d8b0d2c29ab175e2179d6caaf10b155720a64f2063a1249e8523808020f0f46d0de743c566634e9bcf6e2f6bd0d001eb7470cfc322e67165a0b6841251032f8
|
7
|
+
data.tar.gz: 95a1e72eb075129b5e7e01f94b5a6c2341c47314733c38ae0d51b7b8b501d2b453259c03c5698a8c77aa3566d6f9a648350b4d09ed4f9ffbf3e74d07069574fd
|
@@ -39,7 +39,7 @@ jobs:
|
|
39
39
|
docker exec -t test bundle exec rake
|
40
40
|
docker kill test
|
41
41
|
test_330x:
|
42
|
-
runs-on: ubuntu-
|
42
|
+
runs-on: ubuntu-20.04
|
43
43
|
steps:
|
44
44
|
- name: Check out repository
|
45
45
|
uses: actions/checkout@v2
|
@@ -55,7 +55,7 @@ jobs:
|
|
55
55
|
docker exec -t test bundle exec rake
|
56
56
|
docker kill test
|
57
57
|
test_340x:
|
58
|
-
runs-on: ubuntu-
|
58
|
+
runs-on: ubuntu-20.04
|
59
59
|
steps:
|
60
60
|
- name: Check out repository
|
61
61
|
uses: actions/checkout@v2
|
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# oslg
|
2
2
|
|
3
|
-
A logger module for _picky_ [OpenStudio](https://openstudio
|
3
|
+
A logger module for _picky_ [OpenStudio](https://openstudio.net) [Measure](https://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/) developers who wish to select what gets logged to which target (e.g. OpenStudio _runner_ vs custom JSON file). Add:
|
4
4
|
|
5
5
|
```
|
6
6
|
gem "oslg", git: "https://github.com/rd2/oslg", branch: "main"
|
7
7
|
```
|
8
8
|
|
9
|
-
... in a
|
9
|
+
... in a v2.1 [bundled](https://bundler.io) _Measure_ development environment "Gemfile" (or instead as a _gemspec_ dependency), and then run:
|
10
10
|
|
11
11
|
```
|
12
|
-
bundle install
|
12
|
+
bundle install (or 'bundle update')
|
13
13
|
```
|
14
14
|
|
15
15
|
### OpenStudio & EnergyPlus
|
@@ -21,7 +21,7 @@ In most cases, critical (and many non-critical) OpenStudio anomalies will be cau
|
|
21
21
|
As a Ruby module, one can access __oslg__ by _extending_ a measure module or class:
|
22
22
|
|
23
23
|
```
|
24
|
-
module
|
24
|
+
module M
|
25
25
|
extend OSlg
|
26
26
|
...
|
27
27
|
end
|
@@ -39,56 +39,56 @@ FATAL
|
|
39
39
|
|
40
40
|
DEBUG messages aren't benign at all, but are certainly less informative for the typical Measure user.
|
41
41
|
|
42
|
-
Initially, __oslg__ sets 2x internal
|
42
|
+
Initially, __oslg__ sets 2x internal attributes: `level` (INFO) and `status` (< DEBUG). The `level` attribute is a user-set threshold below which less severe logs (e.g. DEBUG) are ignored. For instance, if `level` were _reset_ to DEBUG (e.g. `M.reset(M::DEBUG)`), then all DEBUG messages would also be logged. The `status` attribute is reset with each new log entry if the latter's log level is more severe than its predecessor (e.g. `status == M::FATAL` if there is a single log entry registered as FATAL). To check the curent __oslg__ `status` (true or false):
|
43
43
|
|
44
44
|
```
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
M.debug?
|
46
|
+
M.warn?
|
47
|
+
M.error?
|
48
|
+
M.fatal?
|
49
49
|
```
|
50
50
|
|
51
|
-
It's sometimes not a bad idea to rely on a _clean_ slate (e.g. within RSpecs).
|
51
|
+
It's sometimes not a bad idea to rely on a _clean_ slate (e.g. within RSpecs). The following purges all previous logs and resets `level` (INFO) and `status` (< DEBUG) - use with caution in production code!
|
52
52
|
|
53
53
|
```
|
54
|
-
|
54
|
+
M.clean!
|
55
55
|
```
|
56
56
|
|
57
57
|
EnergyPlus will run, with e.g. out-of-range material or fluid properties, while logging ERROR messages in the process. It remains up to users to decide what to do with simulation results. We recommend something similar with __oslg__. For instance, we suggest logging as __FATAL__ any error that should halt measure processes and prevent OpenStudio from launching an EnergyPlus simulation. This could be missing or poorly-defined OpenStudio files.
|
58
58
|
|
59
59
|
```
|
60
|
-
|
60
|
+
M.log(M::FATAL, "Missing input JSON file")
|
61
61
|
```
|
62
62
|
|
63
|
-
Consider logging non-fatal __ERROR__ messages when encountering invalid OpenStudio file entries, i.e. well-defined, yet invalid vis-à-vis EnergyPlus limitations. The invalid object could be simply ignored, while the measure pursues its (otherwise valid) calculations ... with OpenStudio ultimately launching an EnergyPlus simulation. If a simulation indeed ran (ultimately a go/no-go decision made by the EnergyPlus simulation engine), it would be up to users to decide if simulation results were valid or useful, given the context - maybe based on __oslg__ logged messages. In short, non-fatal ERROR logs should ideally point to bad input users can fix.
|
63
|
+
Consider logging non-fatal __ERROR__ messages when encountering invalid OpenStudio file entries, i.e. well-defined, yet invalid vis-à-vis EnergyPlus limitations. The invalid object could be simply ignored, while the measure pursues its (otherwise valid) calculations ... with OpenStudio ultimately launching an EnergyPlus simulation. If a simulation indeed ran (ultimately a go/no-go decision made by the EnergyPlus simulation engine), it would be up to users to decide if simulation results were valid or useful, given the context - maybe based on __oslg__ logged messages. In short, non-fatal ERROR logs should ideally point to bad input (that users can fix).
|
64
64
|
|
65
65
|
```
|
66
|
-
|
66
|
+
M.log(M::ERROR, "Measure won't process MASSLESS materials")
|
67
67
|
```
|
68
68
|
|
69
69
|
A __WARNING__ could be triggered from inherit limitations of the underlying measure scope or methodology (something users may have little knowledge of beforehand). For instance, surfaces the size of dinner plates are often artifacts of poor 3D model design. It's usually not a good idea to have such small surfaces in an OpenStudio model, but neither OpenStudio nor EnergyPlus will necessarily warn users of such occurrences. It's up to users to decide on the suitable course of action.
|
70
70
|
|
71
71
|
```
|
72
|
-
|
72
|
+
M.log(M::WARN, "Surface area < 100cm2")
|
73
73
|
```
|
74
74
|
|
75
75
|
There's also the possibility of logging __INFO__-rmative messages for users, e.g. the final state of a measure variable before exiting.
|
76
76
|
|
77
77
|
```
|
78
|
-
|
78
|
+
M.log(M::INFO, "Envelope compliant to prescriptive code requirements")
|
79
79
|
```
|
80
80
|
|
81
81
|
Finally, a number of sanity checks are likely warranted to ensure Ruby doesn't crash (e.g., invalid access to uninitialized variables), especially for lower-level functions. We suggest implementing safe fallbacks when this occurs, but __DEBUG__ errors could nonetheless be triggered to signal a bug.
|
82
82
|
|
83
83
|
```
|
84
|
-
|
84
|
+
M.log(M::DEBUG, "Hash? expecting Array (method)")
|
85
85
|
```
|
86
86
|
|
87
87
|
All log entries are stored in a single Ruby _Array_, with each individual log entry as a Ruby _Hash_ with 2x _keys_ ```:level``` and ```:message```, e.g.:
|
88
88
|
|
89
89
|
```
|
90
|
-
|
91
|
-
puts "Uh-oh: #{log[:message]}" if log[:level] >
|
90
|
+
M.logs.each do |log|
|
91
|
+
puts "Uh-oh: #{log[:message]}" if log[:level] > M::INFO
|
92
92
|
end
|
93
93
|
```
|
94
94
|
|
@@ -96,23 +96,23 @@ These logs can be first _mapped_ to other structures (then edited), depending on
|
|
96
96
|
|
97
97
|
### Preset log templates
|
98
98
|
|
99
|
-
Typically, developers would first catch bad input, log an error message and possibly exit by returning
|
99
|
+
Typically, developers would first catch bad input, log an error message and possibly exit by returning an object (e.g. __false__, __nil__), e.g.:
|
100
100
|
|
101
101
|
```
|
102
102
|
unless var.is_a?(Array)
|
103
|
-
|
103
|
+
M.log(M::DEBUG, "#{var.class}? expecting Array (method)")
|
104
104
|
return false
|
105
105
|
end
|
106
106
|
```
|
107
107
|
|
108
|
-
The following are __oslg__ one-liner methods that _log & return_ in one go. These are for some of the most common checks OpenStudio SDK Ruby developers are likely to need.
|
108
|
+
The following are __oslg__ one-liner methods that _log & return_ in one go. These are for some of the most common checks OpenStudio SDK Ruby developers are likely to need. The methods require _valid_ arguments for __oslg__ to actually log. Although often expecting either strings or integers as arguments, the methods will try to convert other types to strings (e.g. classes, numbers, even entire arrays) or integers if possible.
|
109
109
|
|
110
110
|
---
|
111
111
|
|
112
112
|
__invalid__: for logging e.g. uninitialized or nilled objects:
|
113
113
|
|
114
114
|
```
|
115
|
-
return
|
115
|
+
return M.invalid("area", "sum", 0, M::ERROR, false) unless area
|
116
116
|
```
|
117
117
|
|
118
118
|
This logs an ERROR message informing users that an invalid object, 'area', was caught while running method 'sum', and then exits by returning _false_. The logged message would be:
|
@@ -125,8 +125,8 @@ The 3rd argument (e.g. _0_) is ignored unless `> 0` - a useful option when asser
|
|
125
125
|
|
126
126
|
```
|
127
127
|
def sum(areas, units)
|
128
|
-
return
|
129
|
-
return
|
128
|
+
return M.invalid("areas", "sum", 1) unless areas.respond_to?(:to_f)
|
129
|
+
return M.invalid("units", "sum", 2) unless units.respond_to?(:to_s)
|
130
130
|
...
|
131
131
|
end
|
132
132
|
```
|
@@ -144,7 +144,7 @@ The first 2x __invalid__ method arguments (faulty object ID, calling method ID)
|
|
144
144
|
__mismatch__: for logging incompatible instances vs classes:
|
145
145
|
|
146
146
|
```
|
147
|
-
return
|
147
|
+
return M.mismatch("areas", areas, Array, "sum") unless areas.is_a?(Array)
|
148
148
|
```
|
149
149
|
|
150
150
|
If 'areas' were a _String_, __mismatch__ would generate the following DEBUG log message (before returning _nil_):
|
@@ -153,30 +153,30 @@ If 'areas' were a _String_, __mismatch__ would generate the following DEBUG log
|
|
153
153
|
"'areas' String? expecting Array (sum)"
|
154
154
|
```
|
155
155
|
|
156
|
-
These 4x __mismatch__ arguments are required (an object ID, a valid Ruby object, the mismatched Ruby class, and the calling method ID). As a safeguard, __oslg__ will NOT log a _mismatch_ if the object is an actual instance of the class. As with __invalid__, there are 2x optional _terminal_ arguments, e.g. `
|
156
|
+
These 4x __mismatch__ arguments are required (an object ID, a valid Ruby object, the mismatched Ruby class, and the calling method ID). As a safeguard, __oslg__ will NOT log a _mismatch_ if the object is an actual instance of the class. As with __invalid__, there are 2x optional _terminal_ arguments, e.g. `M::ERROR, false)`.
|
157
157
|
|
158
158
|
---
|
159
159
|
|
160
160
|
__hashkey__: for logging missing _Hash_ keys:
|
161
161
|
|
162
162
|
```
|
163
|
-
return
|
163
|
+
return M.hashkey("faces", faces, :area, "sum") unless faces.key?(:area)
|
164
164
|
```
|
165
165
|
|
166
|
-
If the _Hash_ `faces` does not hold `:area` as one of its keys, then
|
166
|
+
If the _Hash_ `faces` does not hold `:area` as one of its keys, then __hashkey__ would generate the following DEBUG log message (before returning _nil_):
|
167
167
|
|
168
168
|
```
|
169
|
-
"'
|
169
|
+
"Missing 'area' key in 'faces' Hash (sum)"
|
170
170
|
```
|
171
171
|
|
172
|
-
Similar to __mismatch__, the method __hashkey__ requires 4x arguments (a _Hash_ ID, a valid Ruby _Hash_, the missing _key_, and the calling method ID). There are also 2x optional _terminal_ arguments, e.g. `
|
172
|
+
Similar to __mismatch__, the method __hashkey__ requires 4x arguments (a _Hash_ ID, a valid Ruby _Hash_, the missing _key_, and the calling method ID). There are also 2x optional _terminal_ arguments, e.g. `M::ERROR, false)`.
|
173
173
|
|
174
174
|
---
|
175
175
|
|
176
176
|
__empty__: for logging empty _Enumerable_ (e.g. _Array_, _Hash_) instances or uninitialized boost optionals (e.g. uninitialized _ThermalZone_ object of an _OpenStudio Space_):
|
177
177
|
|
178
178
|
```
|
179
|
-
return
|
179
|
+
return M.empty("faces", "sum", M::ERROR, false) if faces.empty?
|
180
180
|
```
|
181
181
|
|
182
182
|
An empty `faces` _Hash_ would generate the following ERROR log message (before returning _false_):
|
@@ -192,14 +192,14 @@ Again, the first 2x arguments are required; the last 2x are optional.
|
|
192
192
|
__zero__: for logging zero'ed (or nearly-zero'ed) values:
|
193
193
|
|
194
194
|
```
|
195
|
-
|
196
|
-
|
195
|
+
M.zero("area", "sum", M::FATAL, false) if area.zero?
|
196
|
+
M.zero("area", "sum", M::FATAL, false) if area.abs < TOL
|
197
197
|
```
|
198
198
|
... generating the following FATAL log message (before returning _false_):
|
199
199
|
|
200
200
|
```
|
201
|
-
"'area'
|
202
|
-
"'area'
|
201
|
+
"Zero 'area' (sum)"
|
202
|
+
"Zero 'area' (sum)"
|
203
203
|
```
|
204
204
|
|
205
205
|
And again, the first 2x arguments are required; the last 2x are optional.
|
@@ -209,12 +209,16 @@ And again, the first 2x arguments are required; the last 2x are optional.
|
|
209
209
|
__negative__: for logging negative (< 0) values:
|
210
210
|
|
211
211
|
```
|
212
|
-
|
212
|
+
M.negative("area", "sum", M::FATAL, false) if area < 0
|
213
213
|
```
|
214
214
|
... generating this FATAL log message (before returning _false_):
|
215
215
|
|
216
216
|
```
|
217
|
-
"'area'
|
217
|
+
"Negative 'area' (sum)"
|
218
218
|
```
|
219
219
|
|
220
220
|
You guessed it: the first 2x arguments are required; the last 2x as optionals.
|
221
|
+
|
222
|
+
---
|
223
|
+
|
224
|
+
Look up the full __oslg__ API [here](https://www.rubydoc.info/gems/oslg).
|
data/Rakefile
CHANGED
data/lib/oslg/oslog.rb
CHANGED
@@ -169,30 +169,34 @@ module OSlg
|
|
169
169
|
##
|
170
170
|
# Log template 'invalid object' message and return user-set object.
|
171
171
|
#
|
172
|
-
# @param id [String]
|
172
|
+
# @param id [String] invalid object identifier
|
173
173
|
# @param mth [String] calling method identifier
|
174
|
-
# @param ord [
|
174
|
+
# @param ord [Integer] calling method argument order number of obj (optional)
|
175
175
|
# @param lvl [Integer] DEBUG, INFO, WARN, ERROR or FATAL (optional)
|
176
176
|
# @param res [Object] what to return (optional)
|
177
177
|
#
|
178
|
-
# @return [Object]
|
179
|
-
# @return [Nil] nil if return object
|
178
|
+
# @return [Object] return object if specified by user
|
179
|
+
# @return [Nil] nil if return object undefined
|
180
180
|
def invalid(id = "", mth = "", ord = 0, lvl = DEBUG, res = nil)
|
181
|
-
return
|
182
|
-
return res unless
|
183
|
-
return res unless
|
184
|
-
return res unless
|
185
|
-
|
181
|
+
return res unless id.respond_to?(:to_s)
|
182
|
+
return res unless mth.respond_to?(:to_s)
|
183
|
+
return res unless ord.respond_to?(:to_i)
|
184
|
+
return res unless lvl.respond_to?(:to_i)
|
185
|
+
|
186
|
+
id = id.to_s.strip
|
186
187
|
mth = mth.to_s.strip
|
187
|
-
|
188
|
-
|
189
|
-
|
188
|
+
ord = ord.to_i
|
189
|
+
lvl = lvl.to_i
|
190
|
+
|
190
191
|
id = id[0...60] + " ..." if id.length > 60
|
191
192
|
return res if id.empty?
|
193
|
+
|
194
|
+
mth = mth[0...60] + " ..." if mth.length > 60
|
195
|
+
return res if mth.empty?
|
196
|
+
|
192
197
|
msg = "Invalid '#{id}' "
|
193
|
-
msg += "arg ##{ord} " if ord
|
198
|
+
msg += "arg ##{ord} " if ord > 0
|
194
199
|
msg += "(#{mth})"
|
195
|
-
lvl = lvl.to_i unless lvl.is_a?(Integer)
|
196
200
|
log(lvl, msg) if lvl >= DEBUG && lvl <= FATAL
|
197
201
|
res
|
198
202
|
end
|
@@ -200,32 +204,33 @@ module OSlg
|
|
200
204
|
##
|
201
205
|
# Log template 'instance/class mismatch' message and return user-set object.
|
202
206
|
#
|
203
|
-
# @param id [String]
|
207
|
+
# @param id [String] mismatched object identifier
|
204
208
|
# @param obj [Object] object to validate
|
205
209
|
# @param cl [Class] target class
|
206
210
|
# @param mth [String] calling method identifier
|
207
211
|
# @param lvl [Integer] DEBUG, INFO, WARN, ERROR or FATAL (optional)
|
208
212
|
# @param res [Object] what to return (optional)
|
209
213
|
#
|
210
|
-
# @return [Object]
|
211
|
-
# @return [Nil] nil if return object
|
214
|
+
# @return [Object] return object if specified by user
|
215
|
+
# @return [Nil] nil if return object undefined
|
212
216
|
def mismatch(id = "", obj = nil, cl = nil, mth = "", lvl = DEBUG, res = nil)
|
213
|
-
return
|
214
|
-
return res unless
|
215
|
-
return res
|
216
|
-
return res unless
|
217
|
-
return res unless
|
218
|
-
|
217
|
+
return res unless id.respond_to?(:to_s)
|
218
|
+
return res unless cl.is_a?(Class)
|
219
|
+
return res if obj.is_a?(cl)
|
220
|
+
return res unless mth.respond_to?(:to_s)
|
221
|
+
return res unless lvl.respond_to?(:to_i)
|
222
|
+
|
219
223
|
mth = mth.to_s.strip
|
220
|
-
|
221
|
-
|
222
|
-
|
224
|
+
id = id.to_s.strip
|
225
|
+
lvl = lvl.to_i
|
226
|
+
|
223
227
|
id = id[0...60] + " ..." if id.length > 60
|
224
228
|
return res if id.empty?
|
225
|
-
|
226
|
-
|
229
|
+
|
230
|
+
mth = mth[0...60] + " ..." if mth.length > 60
|
231
|
+
return res if mth.empty?
|
232
|
+
|
227
233
|
msg = "'#{id}' #{obj.class}? expecting #{cl} (#{mth})"
|
228
|
-
lvl = lvl.to_i unless lvl.is_a?(Integer)
|
229
234
|
log(lvl, msg) if lvl >= DEBUG && lvl <= FATAL
|
230
235
|
res
|
231
236
|
end
|
@@ -233,32 +238,33 @@ module OSlg
|
|
233
238
|
##
|
234
239
|
# Log template 'missing hash key' message and return user-set object.
|
235
240
|
#
|
236
|
-
# @param id [String]
|
241
|
+
# @param id [String] Hash identifier
|
237
242
|
# @param hsh [Hash] hash to validate
|
238
|
-
# @param key [Object]
|
243
|
+
# @param key [Object] missing key
|
239
244
|
# @param mth [String] calling method identifier
|
240
245
|
# @param lvl [Integer] DEBUG, INFO, WARN, ERROR or FATAL (optional)
|
241
246
|
# @param res [Object] what to return (optional)
|
242
247
|
#
|
243
|
-
# @return [Object]
|
244
|
-
# @return [Nil] nil if
|
248
|
+
# @return [Object] return object if specified by user
|
249
|
+
# @return [Nil] nil if return object undefined
|
245
250
|
def hashkey(id = "", hsh = {}, key = "", mth = "", lvl = DEBUG, res = nil)
|
246
|
-
return
|
247
|
-
return res unless
|
248
|
-
return res
|
249
|
-
return res unless
|
250
|
-
return res unless
|
251
|
-
|
251
|
+
return res unless id.respond_to?(:to_s)
|
252
|
+
return res unless hsh.is_a?(Hash)
|
253
|
+
return res if hsh.key?(key)
|
254
|
+
return res unless mth.respond_to?(:to_s)
|
255
|
+
return res unless lvl.respond_to?(:to_i)
|
256
|
+
|
257
|
+
id = id.to_s.strip
|
252
258
|
mth = mth.to_s.strip
|
253
|
-
|
254
|
-
|
255
|
-
id = id.to_s.strip
|
259
|
+
lvl = lvl.to_i
|
260
|
+
|
256
261
|
id = id[0...60] + " ..." if id.length > 60
|
257
262
|
return res if id.empty?
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
263
|
+
|
264
|
+
mth = mth[0...60] + " ..." if mth.length > 60
|
265
|
+
return res if mth.empty?
|
266
|
+
|
267
|
+
msg = "Missing '#{key}' key in '#{id}' Hash (#{mth})"
|
262
268
|
log(lvl, msg) if lvl >= DEBUG && lvl <= FATAL
|
263
269
|
res
|
264
270
|
end
|
@@ -271,21 +277,24 @@ module OSlg
|
|
271
277
|
# @param lvl [Integer] DEBUG, INFO, WARN, ERROR or FATAL (optional)
|
272
278
|
# @param res [Object] what to return (optional)
|
273
279
|
#
|
274
|
-
# @return [Object]
|
275
|
-
# @return [Nil] nil if return object
|
280
|
+
# @return [Object] return object if specified by user
|
281
|
+
# @return [Nil] nil if return object undefined
|
276
282
|
def empty(id = "", mth = "", lvl = DEBUG, res = nil)
|
277
|
-
return
|
278
|
-
return res unless
|
279
|
-
return res unless
|
280
|
-
|
283
|
+
return res unless id.respond_to?(:to_s)
|
284
|
+
return res unless mth.respond_to?(:to_s)
|
285
|
+
return res unless lvl.respond_to?(:to_i)
|
286
|
+
|
287
|
+
id = id.to_s.strip
|
281
288
|
mth = mth.to_s.strip
|
282
|
-
|
283
|
-
|
284
|
-
id = id.to_s.strip
|
289
|
+
lvl = lvl.to_i
|
290
|
+
|
285
291
|
id = id[0...60] + " ..." if id.length > 60
|
286
292
|
return res if id.empty?
|
293
|
+
|
294
|
+
mth = mth[0...60] + " ..." if mth.length > 60
|
295
|
+
return res if mth.empty?
|
296
|
+
|
287
297
|
msg = "Empty '#{id}' (#{mth})"
|
288
|
-
lvl = lvl.to_i unless lvl.is_a?(Integer)
|
289
298
|
log(lvl, msg) if lvl >= DEBUG && lvl <= FATAL
|
290
299
|
res
|
291
300
|
end
|
@@ -293,26 +302,30 @@ module OSlg
|
|
293
302
|
##
|
294
303
|
# Log template 'near zero' message and return user-set object.
|
295
304
|
#
|
296
|
-
# @param id [String]
|
305
|
+
# @param id [String] zero object identifier
|
297
306
|
# @param mth [String] calling method identifier
|
298
307
|
# @param lvl [Integer] DEBUG, INFO, WARN, ERROR or FATAL (optional)
|
299
308
|
# @param res [Object] what to return (optional)
|
300
309
|
#
|
301
|
-
# @return [Object]
|
302
|
-
# @return [Nil] nil if return object
|
310
|
+
# @return [Object] return object if specified by user
|
311
|
+
# @return [Nil] nil if return object undefined
|
303
312
|
def zero(id = "", mth = "", lvl = DEBUG, res = nil)
|
304
|
-
return
|
305
|
-
return res unless
|
306
|
-
return res unless
|
307
|
-
|
313
|
+
return res unless id.respond_to?(:to_s)
|
314
|
+
return res unless mth.respond_to?(:to_s)
|
315
|
+
return res unless lvl.respond_to?(:to_i)
|
316
|
+
|
317
|
+
id = id.to_s.strip
|
308
318
|
mth = mth.to_s.strip
|
309
|
-
|
310
|
-
|
311
|
-
|
319
|
+
ord = ord.to_i
|
320
|
+
lvl = lvl.to_i
|
321
|
+
|
312
322
|
id = id[0...60] + " ..." if id.length > 60
|
313
323
|
return res if id.empty?
|
314
|
-
|
315
|
-
|
324
|
+
|
325
|
+
mth = mth[0...60] + " ..." if mth.length > 60
|
326
|
+
return res if mth.empty?
|
327
|
+
|
328
|
+
msg = "Zero '#{id}' (#{mth})"
|
316
329
|
log(lvl, msg) if lvl >= DEBUG && lvl <= FATAL
|
317
330
|
res
|
318
331
|
end
|
@@ -320,26 +333,30 @@ module OSlg
|
|
320
333
|
##
|
321
334
|
# Log template 'negative' message and return user-set object.
|
322
335
|
#
|
323
|
-
# @param id [String]
|
336
|
+
# @param id [String] negative object identifier
|
324
337
|
# @param mth [String] calling method identifier
|
325
338
|
# @param lvl [Integer] DEBUG, INFO, WARN, ERROR or FATAL (optional)
|
326
339
|
# @param res [Object] what to return (optional)
|
327
340
|
#
|
328
|
-
# @return [Object]
|
329
|
-
# @return [Nil] nil if return object
|
341
|
+
# @return [Object] return object if specified by user
|
342
|
+
# @return [Nil] nil if return object undefined
|
330
343
|
def negative(id = "", mth = "", lvl = DEBUG, res = nil)
|
331
|
-
return
|
332
|
-
return res unless
|
333
|
-
return res unless
|
334
|
-
|
344
|
+
return res unless id.respond_to?(:to_s)
|
345
|
+
return res unless mth.respond_to?(:to_s)
|
346
|
+
return res unless lvl.respond_to?(:to_i)
|
347
|
+
|
348
|
+
id = id.to_s.strip
|
335
349
|
mth = mth.to_s.strip
|
336
|
-
|
337
|
-
|
338
|
-
|
350
|
+
ord = ord.to_i
|
351
|
+
lvl = lvl.to_i
|
352
|
+
|
339
353
|
id = id[0...60] + " ..." if id.length > 60
|
340
354
|
return res if id.empty?
|
341
|
-
|
342
|
-
|
355
|
+
|
356
|
+
mth = mth[0...60] + " ..." if mth.length > 60
|
357
|
+
return res if mth.empty?
|
358
|
+
|
359
|
+
msg = "Negative '#{id}' (#{mth})"
|
343
360
|
log(lvl, msg) if lvl >= DEBUG && lvl <= FATAL
|
344
361
|
res
|
345
362
|
end
|
data/lib/oslg/version.rb
CHANGED
data/oslg.gemspec
CHANGED
@@ -6,14 +6,17 @@ Gem::Specification.new do |s|
|
|
6
6
|
# Specify which files should be added to the gem when it is released.
|
7
7
|
# "git ls-files -z" loads files in the RubyGem that have been added into git.
|
8
8
|
s.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
9
|
-
`git ls-files -z`.split("\x0").reject
|
9
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
10
|
+
f.match(%r{^(test|spec|features)/})
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
14
|
s.name = "oslg"
|
13
15
|
s.version = OSlg::VERSION
|
14
16
|
s.license = "BSD-3-Clause"
|
15
17
|
s.summary = "OpenStudio SDK logger"
|
16
|
-
s.description = "For SDK users who
|
18
|
+
s.description = "For OpenStudio SDK users who wish to select " \
|
19
|
+
"what gets logged to which target."
|
17
20
|
s.authors = ["Denis Bourgeois"]
|
18
21
|
s.email = ["denis@rd2.ca"]
|
19
22
|
s.platform = Gem::Platform::RUBY
|
@@ -27,7 +30,6 @@ Gem::Specification.new do |s|
|
|
27
30
|
s.add_development_dependency "bundler", "~> 2.1"
|
28
31
|
s.add_development_dependency "rake", "~> 13.0"
|
29
32
|
s.add_development_dependency "rspec", "~> 3.11"
|
30
|
-
s.add_development_dependency "yard", "~> 0.9"
|
31
33
|
|
32
34
|
s.metadata["homepage_uri"] = s.homepage
|
33
35
|
s.metadata["source_code_uri"] = "#{s.homepage}/tree/v#{s.version}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oslg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Bourgeois
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,21 +52,8 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.11'
|
55
|
-
|
56
|
-
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.9'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.9'
|
69
|
-
description: For SDK users who select what's logged where.
|
55
|
+
description: For OpenStudio SDK users who wish to select what gets logged to which
|
56
|
+
target.
|
70
57
|
email:
|
71
58
|
- denis@rd2.ca
|
72
59
|
executables: []
|
@@ -89,7 +76,7 @@ licenses:
|
|
89
76
|
- BSD-3-Clause
|
90
77
|
metadata:
|
91
78
|
homepage_uri: https://github.com/rd2/oslg
|
92
|
-
source_code_uri: https://github.com/rd2/oslg/tree/v0.2.
|
79
|
+
source_code_uri: https://github.com/rd2/oslg/tree/v0.2.5
|
93
80
|
bug_tracker_uri: https://github.com/rd2/oslg/issues
|
94
81
|
post_install_message:
|
95
82
|
rdoc_options: []
|