pretty_formatter 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +32 -0
  3. data/lib/pretty_formatter/version.rb +3 -0
  4. data/lib/pretty_formatter.rb +75 -0
  5. data/lib/tasks/pretty_formatter_tasks.rake +4 -0
  6. data/test/dummy/README.rdoc +28 -0
  7. data/test/dummy/Rakefile +6 -0
  8. data/test/dummy/app/assets/javascripts/application.js +16 -0
  9. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  10. data/test/dummy/app/controllers/application_controller.rb +5 -0
  11. data/test/dummy/app/helpers/application_helper.rb +2 -0
  12. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  13. data/test/dummy/bin/bundle +3 -0
  14. data/test/dummy/bin/rails +4 -0
  15. data/test/dummy/bin/rake +4 -0
  16. data/test/dummy/config/application.rb +27 -0
  17. data/test/dummy/config/boot.rb +9 -0
  18. data/test/dummy/config/database.yml +25 -0
  19. data/test/dummy/config/environment.rb +5 -0
  20. data/test/dummy/config/environments/development.rb +27 -0
  21. data/test/dummy/config/environments/production.rb +80 -0
  22. data/test/dummy/config/environments/test.rb +36 -0
  23. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  24. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  25. data/test/dummy/config/initializers/inflections.rb +16 -0
  26. data/test/dummy/config/initializers/mime_types.rb +5 -0
  27. data/test/dummy/config/initializers/secret_token.rb +12 -0
  28. data/test/dummy/config/initializers/session_store.rb +3 -0
  29. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  30. data/test/dummy/config/locales/en.yml +23 -0
  31. data/test/dummy/config/routes.rb +49 -0
  32. data/test/dummy/config.ru +4 -0
  33. data/test/dummy/db/development.sqlite3 +0 -0
  34. data/test/dummy/db/test.sqlite3 +0 -0
  35. data/test/dummy/log/development.log +191 -0
  36. data/test/dummy/log/test.log +1450 -0
  37. data/test/dummy/public/404.html +27 -0
  38. data/test/dummy/public/422.html +26 -0
  39. data/test/dummy/public/500.html +26 -0
  40. data/test/dummy/public/favicon.ico +0 -0
  41. data/test/dummy/tmp/pids/server.pid +1 -0
  42. data/test/pretty_formatter_test.rb +75 -0
  43. data/test/test_helper.rb +15 -0
  44. metadata +152 -0
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
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
+ <p>If you are the application owner check the logs for more information.</p>
26
+ </body>
27
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
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,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
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
+ <p>If you are the application owner check the logs for more information.</p>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1 @@
1
+ 95371
@@ -0,0 +1,75 @@
1
+ require 'test_helper'
2
+
3
+ class PrettyFormatterTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, PrettyFormatter
6
+ end
7
+
8
+ test 'add color green to DEBUG severity' do
9
+ PrettyFormatter.verbose = false
10
+ formatter = PrettyFormatter.formatter
11
+
12
+ assert_equal formatter.call('DEBUG', DateTime.now, 'Test', 'Testing...'),
13
+ "\e[32mDEBUG\e[0m Testing...\n"
14
+ end
15
+
16
+ test 'add color white to INFO severity' do
17
+ PrettyFormatter.verbose = false
18
+ formatter = PrettyFormatter.formatter
19
+
20
+ assert_equal formatter.call('INFO', DateTime.now, 'Test', 'Testing...'),
21
+ "\e[37mINFO\e[0m Testing...\n"
22
+ end
23
+
24
+ test 'add color yellow to WARN severity' do
25
+ PrettyFormatter.verbose = false
26
+ formatter = PrettyFormatter.formatter
27
+
28
+ assert_equal formatter.call('WARN', DateTime.now, 'Test', 'Testing...'),
29
+ "\e[33mWARN\e[0m Testing...\n"
30
+ end
31
+
32
+ test 'add color red to ERROR severity' do
33
+ PrettyFormatter.verbose = false
34
+ formatter = PrettyFormatter.formatter
35
+
36
+ assert_equal formatter.call('ERROR', DateTime.now, 'Test', 'Testing...'),
37
+ "\e[31mERROR\e[0m Testing...\n"
38
+ end
39
+
40
+ test 'add color red to FATAL severity' do
41
+ PrettyFormatter.verbose = false
42
+ formatter = PrettyFormatter.formatter
43
+
44
+ assert_equal formatter.call('FATAL', DateTime.now, 'Test', 'Testing...'),
45
+ "\e[31mFATAL\e[0m Testing...\n"
46
+ end
47
+
48
+ test 'add color blue to any other severity' do
49
+ PrettyFormatter.verbose = false
50
+ formatter = PrettyFormatter.formatter
51
+
52
+ assert_equal formatter.call('UNKNOWN', DateTime.now, 'Test', 'Testing...'),
53
+ "\e[34mUNKNOWN\e[0m Testing...\n"
54
+ end
55
+
56
+ test 'verbose mode add host and timestamp to log' do
57
+ PrettyFormatter.verbose = true
58
+ formatter = PrettyFormatter.formatter
59
+
60
+ log_line = formatter.call('INFO', DateTime.now, 'Test', 'Testing...')
61
+
62
+ assert log_line.match(/\d{4}(-\d{2}){2}T(\d{2}:){2}\d{2}\./).present?
63
+ assert log_line.match(/(\S)+\.(\d)+\s{2}/).present?
64
+ assert log_line.include?("\e[37mINFO\e[0m Testing...\n")
65
+ end
66
+
67
+ test 'verbose mode include custom string in log' do
68
+ PrettyFormatter.custom = 'TEST'
69
+ PrettyFormatter.verbose = true
70
+ formatter = PrettyFormatter.formatter
71
+
72
+ log_line = formatter.call('INFO', DateTime.now, 'Test', 'Testing...')
73
+ assert log_line.start_with?('TEST')
74
+ end
75
+ end
@@ -0,0 +1,15 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ # Load support files
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ # Load fixtures from the engine
13
+ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
15
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pretty_formatter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mario A. Chavez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A Rails log formatter that improves the log format, using colors and
42
+ adding additional information to the log.
43
+ email:
44
+ - mario.chavez@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - lib/pretty_formatter/version.rb
50
+ - lib/pretty_formatter.rb
51
+ - lib/tasks/pretty_formatter_tasks.rake
52
+ - Rakefile
53
+ - test/dummy/app/assets/javascripts/application.js
54
+ - test/dummy/app/assets/stylesheets/application.css
55
+ - test/dummy/app/controllers/application_controller.rb
56
+ - test/dummy/app/helpers/application_helper.rb
57
+ - test/dummy/app/views/layouts/application.html.erb
58
+ - test/dummy/bin/bundle
59
+ - test/dummy/bin/rails
60
+ - test/dummy/bin/rake
61
+ - test/dummy/config/application.rb
62
+ - test/dummy/config/boot.rb
63
+ - test/dummy/config/database.yml
64
+ - test/dummy/config/environment.rb
65
+ - test/dummy/config/environments/development.rb
66
+ - test/dummy/config/environments/production.rb
67
+ - test/dummy/config/environments/test.rb
68
+ - test/dummy/config/initializers/backtrace_silencers.rb
69
+ - test/dummy/config/initializers/filter_parameter_logging.rb
70
+ - test/dummy/config/initializers/inflections.rb
71
+ - test/dummy/config/initializers/mime_types.rb
72
+ - test/dummy/config/initializers/secret_token.rb
73
+ - test/dummy/config/initializers/session_store.rb
74
+ - test/dummy/config/initializers/wrap_parameters.rb
75
+ - test/dummy/config/locales/en.yml
76
+ - test/dummy/config/routes.rb
77
+ - test/dummy/config.ru
78
+ - test/dummy/db/development.sqlite3
79
+ - test/dummy/db/test.sqlite3
80
+ - test/dummy/log/development.log
81
+ - test/dummy/log/test.log
82
+ - test/dummy/public/404.html
83
+ - test/dummy/public/422.html
84
+ - test/dummy/public/500.html
85
+ - test/dummy/public/favicon.ico
86
+ - test/dummy/Rakefile
87
+ - test/dummy/README.rdoc
88
+ - test/dummy/tmp/pids/server.pid
89
+ - test/pretty_formatter_test.rb
90
+ - test/test_helper.rb
91
+ homepage: http://mario-chavez.decisionesinteligentes.com
92
+ licenses: []
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.0.3
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Log formatter for Rails, format just like BetterLogging gem.
114
+ test_files:
115
+ - test/dummy/app/assets/javascripts/application.js
116
+ - test/dummy/app/assets/stylesheets/application.css
117
+ - test/dummy/app/controllers/application_controller.rb
118
+ - test/dummy/app/helpers/application_helper.rb
119
+ - test/dummy/app/views/layouts/application.html.erb
120
+ - test/dummy/bin/bundle
121
+ - test/dummy/bin/rails
122
+ - test/dummy/bin/rake
123
+ - test/dummy/config/application.rb
124
+ - test/dummy/config/boot.rb
125
+ - test/dummy/config/database.yml
126
+ - test/dummy/config/environment.rb
127
+ - test/dummy/config/environments/development.rb
128
+ - test/dummy/config/environments/production.rb
129
+ - test/dummy/config/environments/test.rb
130
+ - test/dummy/config/initializers/backtrace_silencers.rb
131
+ - test/dummy/config/initializers/filter_parameter_logging.rb
132
+ - test/dummy/config/initializers/inflections.rb
133
+ - test/dummy/config/initializers/mime_types.rb
134
+ - test/dummy/config/initializers/secret_token.rb
135
+ - test/dummy/config/initializers/session_store.rb
136
+ - test/dummy/config/initializers/wrap_parameters.rb
137
+ - test/dummy/config/locales/en.yml
138
+ - test/dummy/config/routes.rb
139
+ - test/dummy/config.ru
140
+ - test/dummy/db/development.sqlite3
141
+ - test/dummy/db/test.sqlite3
142
+ - test/dummy/log/development.log
143
+ - test/dummy/log/test.log
144
+ - test/dummy/public/404.html
145
+ - test/dummy/public/422.html
146
+ - test/dummy/public/500.html
147
+ - test/dummy/public/favicon.ico
148
+ - test/dummy/Rakefile
149
+ - test/dummy/README.rdoc
150
+ - test/dummy/tmp/pids/server.pid
151
+ - test/pretty_formatter_test.rb
152
+ - test/test_helper.rb