dlog 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/gem.yml +2 -2
- data/lib/dlog.rb +34 -0
- data/vex/gem.rake +1 -1
- metadata +5 -5
data/gem.yml
CHANGED
data/lib/dlog.rb
CHANGED
@@ -232,6 +232,30 @@ module Dlog
|
|
232
232
|
benchmark :debug, args, &block
|
233
233
|
end
|
234
234
|
end
|
235
|
+
|
236
|
+
module Benchslow
|
237
|
+
include Benchmark
|
238
|
+
extend self
|
239
|
+
|
240
|
+
def benchmark(severity, args, &block)
|
241
|
+
args.push "#{args.pop}:" if args.last.is_a?(String)
|
242
|
+
|
243
|
+
start = Time.now
|
244
|
+
r = yield
|
245
|
+
|
246
|
+
timespan = Time.now - start
|
247
|
+
if timespan > 1
|
248
|
+
args.push "%d msecs" % (1000 * timespan)
|
249
|
+
Dlog.log severity, args, 2
|
250
|
+
end
|
251
|
+
|
252
|
+
r
|
253
|
+
rescue
|
254
|
+
args.push "exception raised after #{"%d msecs" % (1000 * (Time.now - start)) }"
|
255
|
+
Dlog.log severity, args, 2
|
256
|
+
raise
|
257
|
+
end
|
258
|
+
end
|
235
259
|
end
|
236
260
|
|
237
261
|
class Object
|
@@ -267,6 +291,16 @@ class Object
|
|
267
291
|
end
|
268
292
|
end
|
269
293
|
|
294
|
+
def benchslow(*args, &block)
|
295
|
+
if Dlog.quiet?
|
296
|
+
Dlog::NoBenchmark
|
297
|
+
elsif args.empty? && !block_given?
|
298
|
+
Dlog::Benchslow
|
299
|
+
else
|
300
|
+
Dlog::Benchslow.benchmark :info, args, &block
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
270
304
|
private
|
271
305
|
|
272
306
|
def dlogger; nil; end
|
data/vex/gem.rake
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- pboy
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-08 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -73,6 +73,6 @@ rubyforge_project:
|
|
73
73
|
rubygems_version: 1.3.7
|
74
74
|
signing_key:
|
75
75
|
specification_version: 3
|
76
|
-
summary: "{d,r}log"
|
76
|
+
summary: "{d,r,s}log"
|
77
77
|
test_files: []
|
78
78
|
|