padrino_gelflogger 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,2 +1,10 @@
1
+ ## v0.1.2
2
+ - changed `bench` log format to: (action 1000ms) - short_message'
3
+ - bench now can all take the full_message for graylog
4
+
5
+ bench("action", Time.local(2012, 12, 20, 20, 12, 00), "message", level=:debug, color=:yellow, full_message="full")
6
+
7
+ the color is not logged, but required for compatibility.
8
+
1
9
  ## v0.1.1
2
10
  - remove dependencies from padrino-core.gem
data/README.md CHANGED
@@ -25,6 +25,10 @@ In your config/boot.rb add something like this:
25
25
  end
26
26
  end
27
27
 
28
+ You can manually log performance stats using `logger.bench`, for example:
29
+
30
+ bench("action", Time.local(2012, 12, 20, 20, 12, 00), "message", level=:debug, color=:yellow, full_message="more info about this run")
31
+
28
32
 
29
33
  More information about the parameters can be found at in the [http://rubydoc.info/github/Graylog2/gelf-rb/master/GELF/Notifier](Graylog2) gem docs.
30
34
 
@@ -33,10 +33,11 @@ module Padrino
33
33
  notify_with_level(gelf_level(level), msg)
34
34
  end
35
35
 
36
- def bench(action, began_at, message, level=:debug, color=:yellow)
37
- duration = Time.now - began_at
38
- short_message = "%s %0.4fms: %s" % [ action, duration, clean(message.to_s) ]
39
- notify_with_level(gelf_level(level), short_message: short_message, _duration: duration, _action: action)
36
+ def bench(action, began_at, message, level=:debug, color=:yellow, full_message=nil)
37
+ duration = ((Time.now - began_at) * 1000).to_i
38
+ short_message = "(%s %dms) - %s" % [ action, duration, clean(message.to_s) ]
39
+ options = {short_message: short_message, full_message: full_message, _Duration: duration, _Action: action}
40
+ notify_with_level(gelf_level(level), options)
40
41
  end
41
42
 
42
43
  private
@@ -1,3 +1,3 @@
1
1
  module PadrinoGelflogger
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -39,9 +39,16 @@ describe Padrino::GelfLogger do
39
39
  end
40
40
 
41
41
  it '#bench' do
42
- mock(@logger).notify_with_level(0, {short_message: 'action 20.0000ms: message', _duration: 20.0, _action: 'action'})
43
- Timecop.freeze(Time.local(2012, 12, 20, 20, 12, 20)) do
44
- @logger.bench("action", Time.local(2012, 12, 20, 20, 12, 00), "message", level=:debug, color=:yellow)
42
+ mock(@logger).notify_with_level(0, {short_message: '(action 1000ms) - short_message', full_message: nil, _Duration: 1000, _Action: 'action'})
43
+ Timecop.freeze(Time.local(2012, 12, 20, 20, 12, 1)) do
44
+ @logger.bench("action", Time.local(2012, 12, 20, 20, 12, 00), "short_message", level=:debug, color=:yellow)
45
+ end
46
+ end
47
+
48
+ it '#bench with optional full_message' do
49
+ mock(@logger).notify_with_level(0, {short_message: '(action 1000ms) - message', full_message: "full", _Duration: 1000, _Action: 'action'})
50
+ Timecop.freeze(Time.local(2012, 12, 20, 20, 12, 1)) do
51
+ @logger.bench("action", Time.local(2012, 12, 20, 20, 12, 00), "message", level=:debug, color=:yellow, full_message="full")
45
52
  end
46
53
  end
47
54
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino_gelflogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-19 00:00:00.000000000Z
12
+ date: 2012-01-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gelf
16
- requirement: &70307894137320 !ruby/object:Gem::Requirement
16
+ requirement: &70254491453560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.3.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70307894137320
24
+ version_requirements: *70254491453560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &70307894136480 !ruby/object:Gem::Requirement
27
+ requirement: &70254491450060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.10.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70307894136480
35
+ version_requirements: *70254491450060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitest-reporters
38
- requirement: &70307894135860 !ruby/object:Gem::Requirement
38
+ requirement: &70254491448200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70307894135860
46
+ version_requirements: *70254491448200
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rr
49
- requirement: &70307894135040 !ruby/object:Gem::Requirement
49
+ requirement: &70254491446380 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70307894135040
57
+ version_requirements: *70254491446380
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: timecop
60
- requirement: &70307894134320 !ruby/object:Gem::Requirement
60
+ requirement: &70254491444140 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70307894134320
68
+ version_requirements: *70254491444140
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
- requirement: &70307894133680 !ruby/object:Gem::Requirement
71
+ requirement: &70254491441460 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70307894133680
79
+ version_requirements: *70254491441460
80
80
  description: Log from Padrino to Graylog2
81
81
  email:
82
82
  - pz@anixe.pl
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  segments:
112
112
  - 0
113
- hash: -2648094041456503352
113
+ hash: 1912002465341032075
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  none: false
116
116
  requirements:
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  segments:
121
121
  - 0
122
- hash: -2648094041456503352
122
+ hash: 1912002465341032075
123
123
  requirements: []
124
124
  rubyforge_project:
125
125
  rubygems_version: 1.8.6