rails-logstasher 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +15 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +100 -0
  4. data/Rakefile +38 -0
  5. data/lib/rails_logstasher.rb +16 -0
  6. data/lib/rails_logstasher/action_controller/log_subscriber.rb +75 -0
  7. data/lib/rails_logstasher/action_view/log_subscriber.rb +31 -0
  8. data/lib/rails_logstasher/active_record/log_subscriber.rb +88 -0
  9. data/lib/rails_logstasher/active_resource/log_subscriber.rb +34 -0
  10. data/lib/rails_logstasher/core_ext/object/blank.rb +110 -0
  11. data/lib/rails_logstasher/event.rb +44 -0
  12. data/lib/rails_logstasher/logger.rb +55 -0
  13. data/lib/rails_logstasher/rack/logger.rb +53 -0
  14. data/lib/rails_logstasher/railtie.rb +70 -0
  15. data/lib/rails_logstasher/tagged_logging.rb +108 -0
  16. data/lib/rails_logstasher/version.rb +3 -0
  17. data/test/action_controller/log_subscriber_test.rb +165 -0
  18. data/test/action_view/log_subscriber_test.rb +89 -0
  19. data/test/active_record/log_subscriber_test.rb +87 -0
  20. data/test/active_resource/log_subscriber_test.rb +42 -0
  21. data/test/core_ext/blank_test.rb +31 -0
  22. data/test/dummy/README.rdoc +261 -0
  23. data/test/dummy/Rakefile +7 -0
  24. data/test/dummy/app/assets/javascripts/application.js +13 -0
  25. data/test/dummy/app/assets/javascripts/widgets.js +2 -0
  26. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  27. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  28. data/test/dummy/app/assets/stylesheets/widgets.css +4 -0
  29. data/test/dummy/app/controllers/application_controller.rb +3 -0
  30. data/test/dummy/app/controllers/log_subscriber_controller.rb +56 -0
  31. data/test/dummy/app/controllers/widgets_controller.rb +83 -0
  32. data/test/dummy/app/helpers/application_helper.rb +2 -0
  33. data/test/dummy/app/helpers/widgets_helper.rb +2 -0
  34. data/test/dummy/app/models/widget.rb +3 -0
  35. data/test/dummy/app/views/customers/_customer.html.erb +1 -0
  36. data/test/dummy/app/views/good_customers/_good_customer.html.erb +1 -0
  37. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  38. data/test/dummy/app/views/test/_customer.erb +1 -0
  39. data/test/dummy/app/views/test/hello_world.erb +1 -0
  40. data/test/dummy/app/views/widgets/_form.html.erb +17 -0
  41. data/test/dummy/app/views/widgets/edit.html.erb +6 -0
  42. data/test/dummy/app/views/widgets/index.html.erb +21 -0
  43. data/test/dummy/app/views/widgets/new.html.erb +5 -0
  44. data/test/dummy/app/views/widgets/show.html.erb +5 -0
  45. data/test/dummy/config.ru +4 -0
  46. data/test/dummy/config/application.rb +69 -0
  47. data/test/dummy/config/boot.rb +10 -0
  48. data/test/dummy/config/database.yml +22 -0
  49. data/test/dummy/config/environment.rb +5 -0
  50. data/test/dummy/config/environments/development.rb +31 -0
  51. data/test/dummy/config/environments/production.rb +64 -0
  52. data/test/dummy/config/environments/test.rb +35 -0
  53. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  54. data/test/dummy/config/initializers/inflections.rb +15 -0
  55. data/test/dummy/config/initializers/mime_types.rb +5 -0
  56. data/test/dummy/config/initializers/secret_token.rb +7 -0
  57. data/test/dummy/config/initializers/session_store.rb +8 -0
  58. data/test/dummy/config/initializers/wrap_parameters.rb +10 -0
  59. data/test/dummy/config/locales/en.yml +5 -0
  60. data/test/dummy/config/routes.rb +69 -0
  61. data/test/dummy/db/migrate/20120927084605_create_widgets.rb +8 -0
  62. data/test/dummy/db/schema.rb +16 -0
  63. data/test/dummy/public/404.html +26 -0
  64. data/test/dummy/public/422.html +26 -0
  65. data/test/dummy/public/500.html +25 -0
  66. data/test/dummy/public/favicon.ico +0 -0
  67. data/test/dummy/script/rails +6 -0
  68. data/test/logger_test.rb +126 -0
  69. data/test/rack/logger_test.rb +68 -0
  70. data/test/rails_logstasher_test.rb +7 -0
  71. data/test/support/fake_models.rb +12 -0
  72. data/test/support/integration_case.rb +5 -0
  73. data/test/support/multibyte_test_helpers.rb +19 -0
  74. data/test/tagged_logging_test.rb +155 -0
  75. data/test/test_helper.rb +40 -0
  76. metadata +219 -0
@@ -0,0 +1,22 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ development:
4
+ adapter: sqlite3
5
+ database: ":memory:"
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: ":memory:"
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: ":memory:"
21
+ pool: 5
22
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,31 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+
26
+ # Do not compress assets
27
+ config.assets.compress = false
28
+
29
+ # Expands the lines which load the assets
30
+ config.assets.debug = true
31
+ end
@@ -0,0 +1,64 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Don't fallback to assets pipeline if a precompiled asset is missed
18
+ config.assets.compile = false
19
+
20
+ # Generate digests for assets URLs
21
+ config.assets.digest = true
22
+
23
+ # Defaults to nil and saved in location specified by config.assets.prefix
24
+ # config.assets.manifest = YOUR_PATH
25
+
26
+ # Specifies the header that your server uses for sending files
27
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # See everything in the log (default is :info)
34
+ # config.log_level = :debug
35
+
36
+ # Prepend all log lines with the following tags
37
+ # config.log_tags = [ :subdomain, :uuid ]
38
+
39
+ # Use a different logger for distributed setups
40
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41
+
42
+ # Use a different cache store in production
43
+ # config.cache_store = :mem_cache_store
44
+
45
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
46
+ # config.action_controller.asset_host = "http://assets.example.com"
47
+
48
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
49
+ # config.assets.precompile += %w( search.js )
50
+
51
+ # Disable delivery errors, bad email addresses will be ignored
52
+ # config.action_mailer.raise_delivery_errors = false
53
+
54
+ # Enable threaded mode
55
+ # config.threadsafe!
56
+
57
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58
+ # the I18n.default_locale when a translation can not be found)
59
+ config.i18n.fallbacks = true
60
+
61
+ # Send deprecation notices to registered listeners
62
+ config.active_support.deprecation = :notify
63
+
64
+ end
@@ -0,0 +1,35 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ config.action_mailer.delivery_method = :test
31
+
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,15 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
11
+ #
12
+ # These inflection rules are supported but not enabled by default:
13
+ # ActiveSupport::Inflector.inflections do |inflect|
14
+ # inflect.acronym 'RESTful'
15
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_token = '52b857e9c917937b7877ebe3e415d4ea7bf6baeb76c394e5b636eb6fe8fd22d1813557b7643692496e1cdbfc680b7ffd4709ad8975f88619dc5a114a20358d2e'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Dummy::Application.config.session_store :active_record_store
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,69 @@
1
+ Dummy::Application.routes.draw do
2
+ resources :widgets
3
+
4
+ # The priority is based upon order of creation:
5
+ # first created -> highest priority.
6
+
7
+ match "show" => "log_subscribers#show"
8
+ match "never_executed" => "log_subscribers#never_executed"
9
+ match "redirector" => "log_subscribers#redirector"
10
+ match "data_sender" => "log_subscribers#data_sender"
11
+ match "file_sender" => "log_subscribers#file_sender"
12
+ match "with_fragment_cache" => "log_subscribers#with_fragment_cache"
13
+ match "with_fragment_cache_and_percent_in_key" => "log_subscribers#with_fragment_cache_and_percent_in_key"
14
+ match "with_page_cache" => "log_subscribers#with_page_cache"
15
+
16
+ # Sample of regular route:
17
+ # match 'products/:id' => 'catalog#view'
18
+ # Keep in mind you can assign values other than :controller and :action
19
+
20
+ # Sample of named route:
21
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
22
+ # This route can be invoked with purchase_url(:id => product.id)
23
+
24
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
25
+ # resources :products
26
+
27
+ # Sample resource route with options:
28
+ # resources :products do
29
+ # member do
30
+ # get 'short'
31
+ # post 'toggle'
32
+ # end
33
+ #
34
+ # collection do
35
+ # get 'sold'
36
+ # end
37
+ # end
38
+
39
+ # Sample resource route with sub-resources:
40
+ # resources :products do
41
+ # resources :comments, :sales
42
+ # resource :seller
43
+ # end
44
+
45
+ # Sample resource route with more complex sub-resources
46
+ # resources :products do
47
+ # resources :comments
48
+ # resources :sales do
49
+ # get 'recent', :on => :collection
50
+ # end
51
+ # end
52
+
53
+ # Sample resource route within a namespace:
54
+ # namespace :admin do
55
+ # # Directs /admin/products/* to Admin::ProductsController
56
+ # # (app/controllers/admin/products_controller.rb)
57
+ # resources :products
58
+ # end
59
+
60
+ # You can have the root of your site routed with "root"
61
+ # just remember to delete public/index.html.
62
+ # root :to => 'welcome#index'
63
+
64
+ # See how all your routes lay out with "rake routes"
65
+
66
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
67
+ # Note: This route will make all actions in every controller accessible via GET requests.
68
+ # match ':controller(/:action(/:id))(.:format)'
69
+ end
@@ -0,0 +1,8 @@
1
+ class CreateWidgets < ActiveRecord::Migration
2
+ def change
3
+ create_table :widgets do |t|
4
+
5
+ t.timestamps
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 0) do
15
+
16
+ end
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,126 @@
1
+ require 'stringio'
2
+ require 'fileutils'
3
+ require 'tempfile'
4
+ require 'test_helper'
5
+
6
+ class BufferedLoggerTest < ActiveSupport::TestCase
7
+ include MultibyteTestHelpers
8
+
9
+ Logger = RailsLogstasher::Logger
10
+
11
+ def setup
12
+ @message = "A debug message"
13
+ @integer_message = 12345
14
+ @output = StringIO.new
15
+ @logger = Logger.new(@output)
16
+ end
17
+
18
+ def test_write_binary_data_to_existing_file
19
+ t = Tempfile.new ['development', 'log']
20
+ t.binmode
21
+ t.write 'hi mom!'
22
+ t.close
23
+
24
+ f = File.open(t.path, 'w')
25
+ f.binmode
26
+
27
+ logger = Logger.new f
28
+ logger.level = Logger::DEBUG
29
+
30
+ str = "\x80"
31
+ str.force_encoding("ASCII-8BIT")
32
+
33
+ logger.add Logger::DEBUG, str
34
+ ensure
35
+ logger.close
36
+ t.close true
37
+ end
38
+
39
+ def test_write_binary_data_create_file
40
+ fname = File.join Dir.tmpdir, 'lol', 'rofl.log'
41
+ FileUtils.mkdir_p File.dirname(fname)
42
+ f = File.open(fname, 'w')
43
+ f.binmode
44
+
45
+ logger = Logger.new f
46
+ logger.level = Logger::DEBUG
47
+
48
+ str = "\x80"
49
+ str.force_encoding("ASCII-8BIT")
50
+
51
+ logger.add Logger::DEBUG, str
52
+ ensure
53
+ logger.close
54
+ File.unlink fname
55
+ end
56
+
57
+ def test_should_log_debugging_message_when_debugging
58
+ @logger.level = Logger::DEBUG
59
+ @logger.add(Logger::DEBUG, @message)
60
+ assert @output.string.include?(@message)
61
+ end
62
+
63
+ def test_should_not_log_debug_messages_when_log_level_is_info
64
+ @logger.level = Logger::INFO
65
+ @logger.add(Logger::DEBUG, @message)
66
+ assert ! @output.string.include?(@message)
67
+ end
68
+
69
+ def test_should_add_message_passed_as_block_when_using_add
70
+ @logger.level = Logger::INFO
71
+ @logger.add(Logger::INFO) {@message}
72
+ assert @output.string.include?(@message)
73
+ end
74
+
75
+ def test_should_add_message_passed_as_block_when_using_shortcut
76
+ @logger.level = Logger::INFO
77
+ @logger.info {@message}
78
+ assert @output.string.include?(@message)
79
+ end
80
+
81
+ def test_should_convert_message_to_string
82
+ @logger.level = Logger::INFO
83
+ @logger.info @integer_message
84
+ assert @output.string.include?(@integer_message.to_s)
85
+ end
86
+
87
+ def test_should_convert_message_to_string_when_passed_in_block
88
+ @logger.level = Logger::INFO
89
+ @logger.info {@integer_message}
90
+ assert @output.string.include?(@integer_message.to_s)
91
+ end
92
+
93
+ def test_should_not_evaluate_block_if_message_wont_be_logged
94
+ @logger.level = Logger::INFO
95
+ evaluated = false
96
+ @logger.add(Logger::DEBUG) {evaluated = true}
97
+ assert evaluated == false
98
+ end
99
+
100
+ def test_should_not_mutate_message
101
+ message_copy = @message.dup
102
+ @logger.info @message
103
+ assert_equal message_copy, @message
104
+ end
105
+
106
+ def test_should_know_if_its_loglevel_is_below_a_given_level
107
+ Logger::Severity.constants.each do |level|
108
+ next if level.to_s == 'UNKNOWN'
109
+ @logger.level = Logger::Severity.const_get(level) - 1
110
+ assert @logger.send("#{level.downcase}?"), "didn't know if it was #{level.downcase}? or below"
111
+ end
112
+ end
113
+
114
+ # This test will fail on JRuby versions lower than 1.7 due to UTF-8 Encoding issues
115
+ # so only run on MRI and JRuby 1.7 and later
116
+ unless defined?(JRUBY_VERSION) && JRUBY_VERSION.to_f < 1.7
117
+ def test_buffer_multibyte
118
+ @logger.info(UNICODE_STRING)
119
+ @logger.info(BYTE_STRING)
120
+ assert @output.string.include?(UNICODE_STRING)
121
+ byte_string = @output.string.dup
122
+ byte_string.force_encoding("ASCII-8BIT")
123
+ assert byte_string.include?(BYTE_STRING)
124
+ end
125
+ end
126
+ end