dlog 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/gem.yml +2 -2
  2. data/lib/dlog.rb +34 -0
  3. data/vex/gem.rake +1 -1
  4. metadata +5 -5
data/gem.yml CHANGED
@@ -1,5 +1,5 @@
1
- version: "0.2.1"
2
- summary: "{d,r}log"
1
+ version: "0.2.3"
2
+ summary: "{d,r,s}log"
3
3
  description: |
4
4
  A logging library mainly for development purposes.
5
5
  homepage: http://github.com/pboy/dlog
@@ -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
@@ -20,7 +20,7 @@ TXT
20
20
 
21
21
  task :install => :build do
22
22
  file = Dir.glob("pkg/*.gem").sort.last
23
- sys "sudo gem install #{file}"
23
+ sys "gem install #{file}"
24
24
  end
25
25
 
26
26
  task :push => :build do
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: 21
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
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-07-29 00:00:00 +02:00
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