solutious-stella 0.6.0 → 0.7.0.001

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/CHANGES.txt +3 -15
  2. data/LICENSE.txt +1 -1
  3. data/README.rdoc +90 -60
  4. data/Rakefile +32 -42
  5. data/bin/stella +138 -0
  6. data/examples/basic/listing_ids.csv +7 -0
  7. data/examples/basic/plan.rb +71 -0
  8. data/lib/stella.rb +57 -104
  9. data/lib/stella/cli.rb +66 -0
  10. data/lib/stella/client.rb +197 -0
  11. data/lib/stella/config.rb +87 -0
  12. data/lib/stella/data.rb +85 -0
  13. data/lib/stella/data/http.rb +2 -257
  14. data/lib/stella/data/http/body.rb +15 -0
  15. data/lib/stella/data/http/request.rb +116 -0
  16. data/lib/stella/data/http/response.rb +92 -0
  17. data/lib/stella/dsl.rb +5 -0
  18. data/lib/stella/engine.rb +55 -0
  19. data/lib/stella/engine/functional.rb +39 -0
  20. data/lib/stella/engine/load.rb +106 -0
  21. data/lib/stella/exceptions.rb +15 -0
  22. data/lib/stella/guidelines.rb +18 -0
  23. data/lib/stella/mixins.rb +2 -0
  24. data/lib/stella/stats.rb +3 -7
  25. data/lib/stella/testplan.rb +95 -220
  26. data/lib/stella/testplan/stats.rb +26 -0
  27. data/lib/stella/testplan/usecase.rb +67 -0
  28. data/lib/stella/utils.rb +126 -0
  29. data/lib/{util → stella/utils}/httputil.rb +0 -0
  30. data/lib/stella/version.rb +15 -0
  31. data/lib/threadify.rb +0 -6
  32. data/stella.gemspec +43 -49
  33. data/support/example_webapp.rb +246 -0
  34. data/support/useragents.txt +75 -0
  35. metadata +66 -31
  36. data/bin/example_test.rb +0 -82
  37. data/bin/example_webapp.rb +0 -63
  38. data/lib/logger.rb +0 -79
  39. data/lib/stella/clients.rb +0 -161
  40. data/lib/stella/command/base.rb +0 -20
  41. data/lib/stella/command/form.rb +0 -36
  42. data/lib/stella/command/get.rb +0 -44
  43. data/lib/stella/common.rb +0 -53
  44. data/lib/stella/crypto.rb +0 -88
  45. data/lib/stella/data/domain.rb +0 -82
  46. data/lib/stella/environment.rb +0 -66
  47. data/lib/stella/functest.rb +0 -105
  48. data/lib/stella/loadtest.rb +0 -186
  49. data/lib/stella/testrunner.rb +0 -64
  50. data/lib/storable.rb +0 -280
  51. data/lib/timeunits.rb +0 -65
  52. data/tryouts/drb/drb_test.rb +0 -65
  53. data/tryouts/drb/open4.rb +0 -19
  54. data/tryouts/drb/slave.rb +0 -27
  55. data/tryouts/oo_tryout.rb +0 -30
@@ -0,0 +1,75 @@
1
+ Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3
2
+ Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3
3
+ Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1
4
+ Opera/9.50 (X11; Linux i686; U; en)
5
+ Mozilla/5.0 (X11; U; FreeBSD amd64; en; rv:1.8.1.16) Gecko/20080827 Epiphany/2.22 Firefox/2.0.0.16
6
+ Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.8.1.16) Gecko/20080827 Firefox/2.0.0.16
7
+ Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.0.2) Gecko/2008100107 Firefox/3.0.2
8
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008111318 Ubuntu/8.10 (intrepid) Firefox/3.0.4
9
+ Opera/9.52 (X11; FreeBSD 7.0-RELEASE amd64; U; en)
10
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.13) Gecko/20080311 (Debian-1.8.1.13+nobinonly-0ubuntu1) Galeon/2.0.4 (Ubuntu 2.0.4-1ubuntu1)
11
+ Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.8.1.16) Gecko/20080827 Galeon/2.0.6 Firefox/2.0.0.16
12
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3
13
+ Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.8.1.16) Gecko/20080827 SeaMonkey/1.1.11
14
+ Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.18) Gecko/20081112 Fedora/1.1.13-1.fc10 SeaMonkey/1.1.13
15
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.4.154.29 Safari/525.19
16
+ Opera/9.51 (X11; Linux i686; U; en)
17
+ Mozilla/5.0 (Windows; U; Windows NT 5.0; de; rv:1.8) Gecko/20051111 Firefox/1.5
18
+ Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
19
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1a2) Gecko/20080829082037 Shiretoko/3.1a2
20
+ Dillo/0.8.6-i18n-misc
21
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061302 Firefox/3.0 Flock/2.0b1
22
+ Opera/9.27 (X11; Linux i686; U; en)
23
+ Opera/10.00 (Windows NT 5.1; U; en) Presto/2.2.0
24
+ Opera/9.27 (Windows NT 5.0; U; de)
25
+ Opera/9.62 (X11; Linux i686; U; de) Presto/2.1.1
26
+ Opera/9.62 (Windows NT 5.1; U; en) Presto/2.1.1
27
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b1pre) Gecko/20080911002759 SeaMonkey/2.0a1pre
28
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080910 Firefox/2.0.0.17 Flock/1.2.6
29
+ Mozilla/5.0 (Windows; U; Windows NT 5.0; de-DE; rv:1.8.1.12) Gecko/20080203 K-Meleon/1.1.4
30
+ Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
31
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.18) Gecko/20081031 SeaMonkey/1.1.13
32
+ Mozilla/5.0 (Windows; U; Windows NT 5.0; de; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
33
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1
34
+ Opera/8.53 (Windows NT 5.1; U; en)
35
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) Gecko/2008112016 Firefox/3.0.4 Flock/2.0.2
36
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.18) Gecko/20081030 Iceape/1.1.13 (Debian-1.1.13-1)
37
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008112309 Iceweasel/3.0.4 (Debian-3.0.4-1)
38
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.8.1.17pre) Gecko/20080716 K-Meleon/1.5.0
39
+ Opera/9.26 (Windows NT 5.0; U; de)
40
+ Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.10 (like Gecko) (Debian)
41
+ Mozilla/5.0 (X11; U; Linux i686; en; rv:1.9.0.4) Gecko/20080528 Epiphany/2.22
42
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1
43
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.14eol) Gecko/20070505 (Debian-1.8.0.15~pre080614d-0etch1) Epiphany/2.14
44
+ Opera/9.52 (X11; Linux i686; U; en)
45
+ Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.11pre) Gecko/20071206 Firefox/2.0.0.11 Navigator/9.0.0.5
46
+ Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
47
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2a1pre) Gecko/20081206 Minefield/3.2a1pre
48
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko Kazehakase/0.5.4 Debian/0.5.4-2.1ubuntu3
49
+ Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Avant Browser)
50
+ Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.36 Safari/525.19
51
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.14eol) Gecko/20070505 Iceape/1.0.9 (Debian-1.0.13~pre080323b-0etch3)
52
+ Opera/9.25 (Windows NT 5.1; U; de)
53
+ Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Opera 7.11 [en]
54
+ Mozilla/4.0 (compatible; MSIE 4.01; Windows NT 5.0; SV1)
55
+ Opera/9.51 (Windows NT 5.1; U; en)
56
+ Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
57
+ Opera/9.61 (Windows NT 5.1; U; en) Presto/2.1.1
58
+ Opera/9.50 (Windows NT 5.1; U; en)
59
+ Opera/9.52 (Windows NT 5.1; U; en)
60
+ Opera/9.24 (Windows NT 5.1; U; it)
61
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/523.12.9 (KHTML, like Gecko) Version/3.0 Safari/523.12.9
62
+ Opera/9.23 (Windows NT 5.1; U; it)
63
+ Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1)
64
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.18) Gecko/20081030 Iceweasel/2.0.0.18 (Debian-2.0.0.18-0etch1)
65
+ Mozilla/5.0 (X11; Linux i686; U;) Gecko/0 Kazehakase/0.4.2 Debian/0.4.2-1etch1
66
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b5pre) Gecko/2008031501 SeaMonkey/2.0a1pre
67
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080219 Firefox/2.0.0.12 Flock/1.1d
68
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.12) Gecko/20080219 Firefox/2.0.0.12 Navigator/9.0.0.6
69
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1a1) Gecko/2008072306 Shiretoko/3.1a1
70
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080211 Firefox/2.0.0.12 Flock/1.0.9
71
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.30 Safari/525.13
72
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b3pre) Gecko/20081201 Minefield/3.1b3pre
73
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.18) Gecko/20081030 Iceweasel/2.0.0.18 (Debian-2.0.0.18-0etch1)
74
+ Opera/10.00 (X11; Linux i686 ; U; en) Presto/2.2.0
75
+ Mozilla/5.0 (Windows; U; Windows NT 6.0; nl-NL) AppleWebKit/525.19 (KHTML, like Gecko) Version/3.1.2 Safari/525.21
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solutious-stella
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0.001
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -9,9 +9,39 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-25 00:00:00 -08:00
12
+ date: 2009-05-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: drydock
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.6.7
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: gibbler
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.6.2
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: storable
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.5.7
44
+ version:
15
45
  - !ruby/object:Gem::Dependency
16
46
  name: httpclient
17
47
  type: :runtime
@@ -20,56 +50,61 @@ dependencies:
20
50
  requirements:
21
51
  - - ">="
22
52
  - !ruby/object:Gem::Version
23
- version: "0"
53
+ version: 2.1.5
24
54
  version:
25
- description: Your friend in performance testing
55
+ description: "Stella: Your friend in performance testing."
26
56
  email: delano@solutious.com
27
- executables: []
28
-
57
+ executables:
58
+ - stella
29
59
  extensions: []
30
60
 
31
61
  extra_rdoc_files:
32
62
  - README.rdoc
33
63
  - LICENSE.txt
64
+ - CHANGES.txt
34
65
  files:
35
66
  - CHANGES.txt
36
67
  - LICENSE.txt
37
68
  - README.rdoc
38
69
  - Rakefile
39
- - bin/example_test.rb
40
- - bin/example_webapp.rb
41
- - lib/logger.rb
70
+ - bin/stella
71
+ - examples/basic/listing_ids.csv
72
+ - examples/basic/plan.rb
42
73
  - lib/stella.rb
43
- - lib/stella/clients.rb
44
- - lib/stella/command/base.rb
45
- - lib/stella/command/form.rb
46
- - lib/stella/command/get.rb
47
- - lib/stella/common.rb
48
- - lib/stella/crypto.rb
49
- - lib/stella/data/domain.rb
74
+ - lib/stella/cli.rb
75
+ - lib/stella/client.rb
76
+ - lib/stella/config.rb
77
+ - lib/stella/data.rb
50
78
  - lib/stella/data/http.rb
51
- - lib/stella/environment.rb
52
- - lib/stella/functest.rb
53
- - lib/stella/loadtest.rb
79
+ - lib/stella/data/http/body.rb
80
+ - lib/stella/data/http/request.rb
81
+ - lib/stella/data/http/response.rb
82
+ - lib/stella/dsl.rb
83
+ - lib/stella/engine.rb
84
+ - lib/stella/engine/functional.rb
85
+ - lib/stella/engine/load.rb
86
+ - lib/stella/exceptions.rb
87
+ - lib/stella/guidelines.rb
88
+ - lib/stella/mixins.rb
54
89
  - lib/stella/stats.rb
55
90
  - lib/stella/testplan.rb
56
- - lib/stella/testrunner.rb
57
- - lib/storable.rb
91
+ - lib/stella/testplan/stats.rb
92
+ - lib/stella/testplan/usecase.rb
93
+ - lib/stella/utils.rb
94
+ - lib/stella/utils/httputil.rb
95
+ - lib/stella/version.rb
58
96
  - lib/threadify.rb
59
- - lib/timeunits.rb
60
- - lib/util/httputil.rb
61
97
  - stella.gemspec
62
- - tryouts/drb/drb_test.rb
63
- - tryouts/drb/open4.rb
64
- - tryouts/drb/slave.rb
65
- - tryouts/oo_tryout.rb
98
+ - support/example_webapp.rb
99
+ - support/useragents.txt
66
100
  has_rdoc: true
67
- homepage: http://github.com/solutious/stella
101
+ homepage: http://solutious.com/projects/stella/
102
+ licenses:
68
103
  post_install_message:
69
104
  rdoc_options:
70
105
  - --line-numbers
71
106
  - --title
72
- - Your friend in performance testing
107
+ - "Stella: Your friend in performance testing."
73
108
  - --main
74
109
  - README.rdoc
75
110
  require_paths:
@@ -89,9 +124,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
124
  requirements: []
90
125
 
91
126
  rubyforge_project: stella
92
- rubygems_version: 1.2.0
127
+ rubygems_version: 1.3.5
93
128
  signing_key:
94
129
  specification_version: 2
95
- summary: Your friend in performance testing
130
+ summary: "Stella: Your friend in performance testing."
96
131
  test_files: []
97
132
 
@@ -1,82 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- # Stella Test DSL - Example 1: Multiple requests, with response data
4
- #
5
- # To run the example test, do the following:
6
- #
7
- # * run bin/example_webapp.rb in an other terminal window. This provides
8
- # an HTTP server for this script to run against.
9
- #
10
- # * run bin/example_test.rb and watch the output!
11
- #
12
- #
13
-
14
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) # Put the local lib first in line
15
-
16
- require 'stella'
17
- require 'yaml'
18
-
19
- include Stella::DSL
20
-
21
- testplan :dsl_example1 do
22
- desc "A basic demonstration of the testplan DSL"
23
- protocol :http
24
- # auth :basic, "stella", "stella"
25
-
26
- post "/upload" do
27
- name "Add Product"
28
- body "bill", "/path/2/file.txt"
29
- header "X-Stella" => "Version #{Stella::VERSION}"
30
- param :convert => true
31
- param :rand => rand
32
-
33
- response 200, 201 do |headers, body|
34
- data = YAML.load(body)
35
- @product_id = data[:id] # Store the response value
36
- end
37
- end
38
-
39
- get "/product" do
40
- name "View Product"
41
- param 'id' => @product_id # Use the value from the previous request
42
-
43
- response 200 do |header, body|
44
- data = YAML.load(body)
45
- #repeat :times => 2, :wait => 1 # Repeat this request
46
- end
47
- end
48
-
49
- get "/product/22" do
50
- name "Product 22"
51
- response 200 do |header, body|
52
- data = YAML.load(body)
53
- end
54
- end
55
-
56
- end
57
-
58
- # Environments
59
- #
60
- # Stella can execute the same test plan on different environments.
61
- # You can specify several environment blocks by giving them unique
62
- # names. Each environment can contain any number of machines.
63
- environment :development do
64
- machines "localhost:3114"
65
- # machine "localhost:3115"
66
- # ...
67
- end
68
-
69
- # Functional Test
70
- #
71
- # A functional test executes the test plan with a single client. It
72
- # produces more output than a load test which can be used to verify
73
- # both that the test plan was written correctly and that the server
74
- # is responding as expected for each request.
75
- functest :integration do
76
- plan :dsl_example1
77
- verbose 2
78
- end
79
-
80
-
81
- run :development, :integration # Run functional test
82
-
@@ -1,63 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- # Use Ruby 1.8
4
-
5
- require "rubygems"
6
- require "rack"
7
- require "sinatra"
8
-
9
- require 'yaml'
10
-
11
- set :run => true
12
- set :environment => :development
13
- set :raise_errors => true
14
- set :port => 3114
15
-
16
- #log = File.new("/dev/null", "a")
17
- #STDOUT.reopen(log)
18
- #STDERR.reopen(log)
19
-
20
-
21
- #use Rack::Auth::Basic do |username, password|
22
- # username == 'stella' && password == 'stella'
23
- #end
24
-
25
- #
26
- # Generates a string of random alphanumeric characters
27
- # These are used as IDs throughout the system
28
- def strand( len )
29
- chars = ("a".."z").to_a + ("0".."9").to_a
30
- newpass = ""
31
- 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }
32
- return newpass
33
- end
34
-
35
- get '/' do
36
- redirect '/product'
37
- end
38
-
39
- get '/product' do
40
- content_type "text/plain"
41
- product = {
42
- :id => (params[:id] || 0).to_s,
43
- :name => "John West Smoked Oysters"
44
- }.to_yaml
45
- end
46
-
47
- get '/product/:id' do
48
- content_type "text/plain"
49
- product = {
50
- :id => params[:id].to_i,
51
- :name => "John West Smoked Oysters"
52
- }.to_yaml
53
- end
54
-
55
- post '/upload' do
56
- content_type "text/plain"
57
- product = {
58
- :id => strand(3),
59
- :name => "John West Smoked Oysters",
60
- :convert => params[:convert] || false,
61
- :rand => params[:rand]
62
- }.to_yaml
63
- end
@@ -1,79 +0,0 @@
1
-
2
-
3
- module Stella
4
- class Logger
5
- attr_accessor :debug_level
6
-
7
- # +args+ is a hash of initialization arguments
8
- # * <tt>:info_logger</tt> The IO class for info level logging. Default: STDOUT
9
- # * <tt>:error_logger</tt> The IO class for error level logging. Default: STDERR
10
- # * <tt>:debug_logger</tt> The IO class for error level logging. Default: STDERR
11
- # * <tt>:debug_level</tt> An integer from 0 to 4 which determines the amount of debugging output. Default: 0.
12
- def initialize(args={})
13
- @debug_level = args[:debug_level] || false
14
- @info_logger = args[:info_logger]
15
- @error_logger = args[:error_logger]
16
- @debug_logger = args[:debug_logger]
17
- end
18
-
19
- # +msgs+ is an array which can contain a list of messages or a symbol and a list of values
20
- # If the first element is a symbol, this will return the output of Stella::Text.msg(msgs[0],msgs[1..-1])
21
- def info(*msgs)
22
- return if !msgs || msgs.empty?
23
- msgs.each do |m|
24
- info_logger.puts m
25
- end
26
- info_logger.flush
27
- end
28
-
29
- def info_logger
30
- @info_logger || $stdout
31
- end
32
- def debug_logger
33
- @debug_logger || $stderr
34
- end
35
- def error_logger
36
- @error_logger || $stderr
37
- end
38
-
39
- def flush
40
- info_logger.flush
41
- error_logger.flush
42
- debug_logger.flush
43
- end
44
-
45
- # Print all messages on a single line.
46
- def info_print(*msgs)
47
- msgs.each do |m|
48
- info_logger.print m
49
- end
50
- info_logger.flush
51
- end
52
-
53
- # Print all messages on a single line.
54
- def info_printf(pattern, *vals)
55
- info_logger.printf(pattern, *vals)
56
- info_logger.flush
57
- end
58
-
59
- def debug(*msgs)
60
- return unless @debug_level
61
- msgs.each do |m|
62
- debug_logger.puts "DEBUG: #{m}"
63
- end
64
- debug_logger.flush
65
- end
66
- def warn(ex, prefix="WARN: ")
67
- error(ex, prefix)
68
- end
69
-
70
- def error(ex, prefix="ERR: ")
71
- msg = (ex.kind_of? String) ? ex : ex.message
72
- error_logger.puts "#{prefix}#{msg}"
73
- return unless @debug_level > 0 && ex.kind_of?(Exception)
74
- error_logger.puts("#{prefix}------------------------------------------")
75
- error_logger.puts("#{prefix}#{ex.backtrace.join("\n")}")
76
- error_logger.puts("#{prefix}------------------------------------------")
77
- end
78
- end
79
- end