grizzled-rails-logger 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 (43) hide show
  1. data/LICENSE.md +31 -0
  2. data/README.md +190 -0
  3. data/Rakefile +118 -0
  4. data/grizzled-rails-logger.gemspec +30 -0
  5. data/lib/grizzled.rb +42 -0
  6. data/lib/grizzled/rails.rb +42 -0
  7. data/lib/grizzled/rails/logger.rb +125 -0
  8. data/rdoc/Grizzled.html +138 -0
  9. data/rdoc/Grizzled/Rails.html +138 -0
  10. data/rdoc/Grizzled/Rails/Logger.html +207 -0
  11. data/rdoc/Grizzled/Rails/Logger/Extension.html +314 -0
  12. data/rdoc/Grizzled/Rails/Logger/Railtie.html +138 -0
  13. data/rdoc/created.rid +4 -0
  14. data/rdoc/images/brick.png +0 -0
  15. data/rdoc/images/brick_link.png +0 -0
  16. data/rdoc/images/bug.png +0 -0
  17. data/rdoc/images/bullet_black.png +0 -0
  18. data/rdoc/images/bullet_toggle_minus.png +0 -0
  19. data/rdoc/images/bullet_toggle_plus.png +0 -0
  20. data/rdoc/images/date.png +0 -0
  21. data/rdoc/images/find.png +0 -0
  22. data/rdoc/images/loadingAnimation.gif +0 -0
  23. data/rdoc/images/macFFBgHack.png +0 -0
  24. data/rdoc/images/package.png +0 -0
  25. data/rdoc/images/page_green.png +0 -0
  26. data/rdoc/images/page_white_text.png +0 -0
  27. data/rdoc/images/page_white_width.png +0 -0
  28. data/rdoc/images/plugin.png +0 -0
  29. data/rdoc/images/ruby.png +0 -0
  30. data/rdoc/images/tag_green.png +0 -0
  31. data/rdoc/images/wrench.png +0 -0
  32. data/rdoc/images/wrench_orange.png +0 -0
  33. data/rdoc/images/zoom.png +0 -0
  34. data/rdoc/index.html +109 -0
  35. data/rdoc/js/darkfish.js +116 -0
  36. data/rdoc/js/jquery.js +32 -0
  37. data/rdoc/js/quicksearch.js +114 -0
  38. data/rdoc/js/thickbox-compressed.js +10 -0
  39. data/rdoc/lib/grizzled/rails/logger_rb.html +71 -0
  40. data/rdoc/lib/grizzled/rails_rb.html +102 -0
  41. data/rdoc/lib/grizzled_rb.html +102 -0
  42. data/rdoc/rdoc.css +763 -0
  43. metadata +100 -0
@@ -0,0 +1,125 @@
1
+ # +Grizzled::Rails::Logger+ is an extension to the stock Rails 3
2
+ # logger, providing additional logging options and capablities.
3
+ #
4
+ # Author:: Brian M. Clapper (mailto:bmc@clapper.org)
5
+ # Copyright:: Copyright (c) 2012 Brian M. Clapper
6
+ # License:: BSD
7
+
8
+ require 'active_support/buffered_logger'
9
+ require 'term/ansicolor'
10
+ require 'ostruct'
11
+
12
+ module Grizzled # :nodoc:
13
+ module Rails # :nodoc:
14
+
15
+ # Logger is the public face of this gem.
16
+ module Logger
17
+
18
+ # Configuration constants
19
+ Configuration = OpenStruct.new(
20
+ :flatten => true,
21
+ :format => '[%T] (%S) %P %M',
22
+ :timeformat => '%Y/%m/%d %H:%M:%S',
23
+ :colorize => true,
24
+ :colors => {
25
+ :debug => Term::ANSIColor.cyan,
26
+ :warn => Term::ANSIColor.yellow + Term::ANSIColor.bold,
27
+ :fatal => Term::ANSIColor.red + Term::ANSIColor.bold,
28
+ :error => Term::ANSIColor.red
29
+ }
30
+ )
31
+
32
+ # Configure the plugin. Use like:
33
+ #
34
+ # Grizzled::Rails::Logger.configure do |cfg|
35
+ # cfg.flatten = false
36
+ # ...
37
+ # end
38
+ def configure(&block)
39
+ block.call Configuration
40
+ end
41
+
42
+ module_function :configure
43
+
44
+ # The actual logging extension sits in here.
45
+ module Extension # :nodoc:
46
+
47
+ Severity = ActiveSupport::BufferedLogger::Severity
48
+ SEVERITIES = Severity.constants.sort_by { |c| Severity.const_get(c) }
49
+
50
+ ERROR = ActiveSupport::BufferedLogger::ERROR
51
+ WARN = ActiveSupport::BufferedLogger::WARN
52
+ FATAL = ActiveSupport::BufferedLogger::FATAL
53
+ DEBUG = ActiveSupport::BufferedLogger::DEBUG
54
+ INFO = ActiveSupport::BufferedLogger::INFO
55
+
56
+ SEVERITY_MAP = {
57
+ DEBUG => :debug,
58
+ WARN => :warn,
59
+ FATAL => :fatal,
60
+ ERROR => :error,
61
+ INFO => :info
62
+ }
63
+
64
+ def self.included(base)
65
+ base.class_eval do
66
+ alias_method_chain :add, :grizzling
67
+ end
68
+ end
69
+
70
+ def exception(message, ex, progname = nil)
71
+ ex_message = "#{ex.class} (backtrace):\n#{ex.backtrace.join("\n")}"
72
+ if message.nil? || (message.length == 0)
73
+ message = "#{ex_message}"
74
+ else
75
+ message << "\n#{ex_message}"
76
+ end
77
+
78
+ do_add(ERROR, message, progname, :flatten => false)
79
+ end
80
+
81
+ def add_with_grizzling(severity, message = nil, progname = nil, &block)
82
+ do_add(severity, message, progname, &block)
83
+ end
84
+
85
+ private
86
+
87
+ def do_add(severity, message, progname, options = {}, &block)
88
+ return if @level > severity
89
+
90
+ if message.nil?
91
+ if block_given?
92
+ if severity < @level
93
+ return true
94
+ end
95
+ message = yield
96
+ end
97
+ end
98
+
99
+ flatten = options.fetch(:flatten, Configuration.flatten)
100
+ message.gsub!("\n", '') if flatten
101
+ time = Time.now.strftime(Configuration.timeformat)
102
+ pid = $$.to_s
103
+ sev = SEVERITIES[severity].to_s
104
+
105
+ message = Configuration.format.gsub("%T", time).
106
+ gsub("%P", pid).
107
+ gsub("%S", sev).
108
+ gsub("%M", message)
109
+
110
+ if Configuration.colorize
111
+ color = Configuration.colors[SEVERITY_MAP[severity]]
112
+ message = "#{color}#{message}#{Term::ANSIColor.reset}" if color
113
+ end
114
+
115
+ add_without_grizzling(severity, message, progname, &block)
116
+ end
117
+ end
118
+
119
+ # Bind it into Rails.
120
+ class Railtie < ::Rails::Railtie
121
+ ActiveSupport::BufferedLogger.send(:include, ::Grizzled::Rails::Logger::Extension)
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,138 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
+
8
+ <title>Module: Grizzled</title>
9
+
10
+ <link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="./js/jquery.js" type="text/javascript" charset="utf-8"></script>
13
+ <script src="./js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="./js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="./js/darkfish.js" type="text/javascript" charset="utf-8"></script>
16
+
17
+ </head>
18
+ <body id="top" class="module">
19
+
20
+ <div id="metadata">
21
+ <div id="home-metadata">
22
+ <div id="home-section" class="section">
23
+ <h3 class="section-header">
24
+ <a href="./index.html">Home</a>
25
+ <a href="./index.html#classes">Classes</a>
26
+ <a href="./index.html#methods">Methods</a>
27
+ </h3>
28
+ </div>
29
+ </div>
30
+
31
+ <div id="file-metadata">
32
+ <div id="file-list-section" class="section">
33
+ <h3 class="section-header">In Files</h3>
34
+ <div class="section-body">
35
+ <ul>
36
+
37
+ <li><a href="./lib/grizzled/rails/logger_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
38
+ class="thickbox" title="lib/grizzled/rails/logger.rb">lib/grizzled/rails/logger.rb</a></li>
39
+
40
+ </ul>
41
+ </div>
42
+ </div>
43
+
44
+
45
+ </div>
46
+
47
+ <div id="class-metadata">
48
+
49
+
50
+
51
+
52
+
53
+ <!-- Namespace Contents -->
54
+ <div id="namespace-list-section" class="section">
55
+ <h3 class="section-header">Namespace</h3>
56
+ <ul class="link-list">
57
+
58
+ <li><span class="type">MODULE</span> <a href="Grizzled/Rails.html">Grizzled::Rails</a></li>
59
+
60
+ </ul>
61
+ </div>
62
+
63
+
64
+
65
+
66
+
67
+ </div>
68
+
69
+ <div id="project-metadata">
70
+
71
+
72
+
73
+ <div id="classindex-section" class="section project-section">
74
+ <h3 class="section-header">Class/Module Index
75
+ <span class="search-toggle"><img src="./images/find.png"
76
+ height="16" width="16" alt="[+]"
77
+ title="show/hide quicksearch" /></span></h3>
78
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
79
+ <fieldset>
80
+ <legend>Quicksearch</legend>
81
+ <input type="text" name="quicksearch" value=""
82
+ class="quicksearch-field" />
83
+ </fieldset>
84
+ </form>
85
+
86
+ <ul class="link-list">
87
+
88
+ <li><a href="./Grizzled.html">Grizzled</a></li>
89
+
90
+ <li><a href="./Grizzled/Rails.html">Grizzled::Rails</a></li>
91
+
92
+ <li><a href="./Grizzled/Rails/Logger.html">Grizzled::Rails::Logger</a></li>
93
+
94
+ <li><a href="./Grizzled/Rails/Logger/Railtie.html">Grizzled::Rails::Logger::Railtie</a></li>
95
+
96
+ </ul>
97
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
98
+ </div>
99
+
100
+
101
+ </div>
102
+ </div>
103
+
104
+ <div id="documentation">
105
+ <h1 class="module">Grizzled</h1>
106
+
107
+ <div id="description" class="description">
108
+
109
+ </div><!-- description -->
110
+
111
+
112
+
113
+
114
+ <div id="5Buntitled-5D" class="documentation-section">
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+ <!-- Methods -->
124
+
125
+ </div><!-- 5Buntitled-5D -->
126
+
127
+
128
+ </div><!-- documentation -->
129
+
130
+ <div id="validator-badges">
131
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
132
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
133
+ Rdoc Generator</a> 2</small>.</p>
134
+ </div>
135
+
136
+ </body>
137
+ </html>
138
+
@@ -0,0 +1,138 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
+
8
+ <title>Module: Grizzled::Rails</title>
9
+
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
13
+ <script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
16
+
17
+ </head>
18
+ <body id="top" class="module">
19
+
20
+ <div id="metadata">
21
+ <div id="home-metadata">
22
+ <div id="home-section" class="section">
23
+ <h3 class="section-header">
24
+ <a href="../index.html">Home</a>
25
+ <a href="../index.html#classes">Classes</a>
26
+ <a href="../index.html#methods">Methods</a>
27
+ </h3>
28
+ </div>
29
+ </div>
30
+
31
+ <div id="file-metadata">
32
+ <div id="file-list-section" class="section">
33
+ <h3 class="section-header">In Files</h3>
34
+ <div class="section-body">
35
+ <ul>
36
+
37
+ <li><a href="../lib/grizzled/rails/logger_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
38
+ class="thickbox" title="lib/grizzled/rails/logger.rb">lib/grizzled/rails/logger.rb</a></li>
39
+
40
+ </ul>
41
+ </div>
42
+ </div>
43
+
44
+
45
+ </div>
46
+
47
+ <div id="class-metadata">
48
+
49
+
50
+
51
+
52
+
53
+ <!-- Namespace Contents -->
54
+ <div id="namespace-list-section" class="section">
55
+ <h3 class="section-header">Namespace</h3>
56
+ <ul class="link-list">
57
+
58
+ <li><span class="type">MODULE</span> <a href="Rails/Logger.html">Grizzled::Rails::Logger</a></li>
59
+
60
+ </ul>
61
+ </div>
62
+
63
+
64
+
65
+
66
+
67
+ </div>
68
+
69
+ <div id="project-metadata">
70
+
71
+
72
+
73
+ <div id="classindex-section" class="section project-section">
74
+ <h3 class="section-header">Class/Module Index
75
+ <span class="search-toggle"><img src="../images/find.png"
76
+ height="16" width="16" alt="[+]"
77
+ title="show/hide quicksearch" /></span></h3>
78
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
79
+ <fieldset>
80
+ <legend>Quicksearch</legend>
81
+ <input type="text" name="quicksearch" value=""
82
+ class="quicksearch-field" />
83
+ </fieldset>
84
+ </form>
85
+
86
+ <ul class="link-list">
87
+
88
+ <li><a href="../Grizzled.html">Grizzled</a></li>
89
+
90
+ <li><a href="../Grizzled/Rails.html">Grizzled::Rails</a></li>
91
+
92
+ <li><a href="../Grizzled/Rails/Logger.html">Grizzled::Rails::Logger</a></li>
93
+
94
+ <li><a href="../Grizzled/Rails/Logger/Railtie.html">Grizzled::Rails::Logger::Railtie</a></li>
95
+
96
+ </ul>
97
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
98
+ </div>
99
+
100
+
101
+ </div>
102
+ </div>
103
+
104
+ <div id="documentation">
105
+ <h1 class="module">Grizzled::Rails</h1>
106
+
107
+ <div id="description" class="description">
108
+
109
+ </div><!-- description -->
110
+
111
+
112
+
113
+
114
+ <div id="5Buntitled-5D" class="documentation-section">
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+ <!-- Methods -->
124
+
125
+ </div><!-- 5Buntitled-5D -->
126
+
127
+
128
+ </div><!-- documentation -->
129
+
130
+ <div id="validator-badges">
131
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
132
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
133
+ Rdoc Generator</a> 2</small>.</p>
134
+ </div>
135
+
136
+ </body>
137
+ </html>
138
+
@@ -0,0 +1,207 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
+
8
+ <title>Module: Grizzled::Rails::Logger</title>
9
+
10
+ <link rel="stylesheet" href="../../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../../js/jquery.js" type="text/javascript" charset="utf-8"></script>
13
+ <script src="../../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="../../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="../../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
16
+
17
+ </head>
18
+ <body id="top" class="module">
19
+
20
+ <div id="metadata">
21
+ <div id="home-metadata">
22
+ <div id="home-section" class="section">
23
+ <h3 class="section-header">
24
+ <a href="../../index.html">Home</a>
25
+ <a href="../../index.html#classes">Classes</a>
26
+ <a href="../../index.html#methods">Methods</a>
27
+ </h3>
28
+ </div>
29
+ </div>
30
+
31
+ <div id="file-metadata">
32
+ <div id="file-list-section" class="section">
33
+ <h3 class="section-header">In Files</h3>
34
+ <div class="section-body">
35
+ <ul>
36
+
37
+ <li><a href="../../lib/grizzled/rails/logger_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
38
+ class="thickbox" title="lib/grizzled/rails/logger.rb">lib/grizzled/rails/logger.rb</a></li>
39
+
40
+ </ul>
41
+ </div>
42
+ </div>
43
+
44
+
45
+ </div>
46
+
47
+ <div id="class-metadata">
48
+
49
+
50
+
51
+
52
+
53
+ <!-- Namespace Contents -->
54
+ <div id="namespace-list-section" class="section">
55
+ <h3 class="section-header">Namespace</h3>
56
+ <ul class="link-list">
57
+
58
+ <li><span class="type">CLASS</span> <a href="Logger/Railtie.html">Grizzled::Rails::Logger::Railtie</a></li>
59
+
60
+ </ul>
61
+ </div>
62
+
63
+
64
+
65
+ <!-- Method Quickref -->
66
+ <div id="method-list-section" class="section">
67
+ <h3 class="section-header">Methods</h3>
68
+ <ul class="link-list">
69
+
70
+ <li><a href="#method-c-configure">::configure</a></li>
71
+
72
+ </ul>
73
+ </div>
74
+
75
+
76
+
77
+ </div>
78
+
79
+ <div id="project-metadata">
80
+
81
+
82
+
83
+ <div id="classindex-section" class="section project-section">
84
+ <h3 class="section-header">Class/Module Index
85
+ <span class="search-toggle"><img src="../../images/find.png"
86
+ height="16" width="16" alt="[+]"
87
+ title="show/hide quicksearch" /></span></h3>
88
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
89
+ <fieldset>
90
+ <legend>Quicksearch</legend>
91
+ <input type="text" name="quicksearch" value=""
92
+ class="quicksearch-field" />
93
+ </fieldset>
94
+ </form>
95
+
96
+ <ul class="link-list">
97
+
98
+ <li><a href="../../Grizzled.html">Grizzled</a></li>
99
+
100
+ <li><a href="../../Grizzled/Rails.html">Grizzled::Rails</a></li>
101
+
102
+ <li><a href="../../Grizzled/Rails/Logger.html">Grizzled::Rails::Logger</a></li>
103
+
104
+ <li><a href="../../Grizzled/Rails/Logger/Railtie.html">Grizzled::Rails::Logger::Railtie</a></li>
105
+
106
+ </ul>
107
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
108
+ </div>
109
+
110
+
111
+ </div>
112
+ </div>
113
+
114
+ <div id="documentation">
115
+ <h1 class="module">Grizzled::Rails::Logger</h1>
116
+
117
+ <div id="description" class="description">
118
+
119
+ <p><a href="Logger.html">Logger</a> is the public face of this gem.</p>
120
+
121
+ </div><!-- description -->
122
+
123
+
124
+
125
+
126
+ <div id="5Buntitled-5D" class="documentation-section">
127
+
128
+
129
+
130
+
131
+
132
+ <!-- Constants -->
133
+ <div id="constants-list" class="section">
134
+ <h3 class="section-header">Constants</h3>
135
+ <dl>
136
+
137
+ <dt><a name="Configuration">Configuration</a></dt>
138
+
139
+ <dd class="description"><p><a href="Logger.html#Configuration">Configuration</a> constants</p></dd>
140
+
141
+
142
+ </dl>
143
+ </div>
144
+
145
+
146
+
147
+
148
+ <!-- Methods -->
149
+
150
+ <div id="public-class-method-details" class="method-section section">
151
+ <h3 class="section-header">Public Class Methods</h3>
152
+
153
+
154
+ <div id="configure-method" class="method-detail ">
155
+ <a name="method-c-configure"></a>
156
+
157
+
158
+ <div class="method-heading">
159
+ <span class="method-name">configure</span><span
160
+ class="method-args">(&block)</span>
161
+ <span class="method-click-advice">click to toggle source</span>
162
+ </div>
163
+
164
+
165
+ <div class="method-description">
166
+
167
+ <p>Configure the plugin. Use like:</p>
168
+
169
+ <pre>Grizzled::Rails::Logger.configure do |cfg|
170
+ cfg.flatten = false
171
+ ...
172
+ end</pre>
173
+
174
+
175
+
176
+ <div class="method-source-code" id="configure-source">
177
+ <pre>
178
+ <span class="ruby-comment"># File lib/grizzled/rails/logger.rb, line 38</span>
179
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">configure</span>(&amp;<span class="ruby-identifier">block</span>)
180
+ <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span> <span class="ruby-constant">Configuration</span>
181
+ <span class="ruby-keyword">end</span></pre>
182
+ </div><!-- configure-source -->
183
+
184
+ </div>
185
+
186
+
187
+
188
+
189
+ </div><!-- configure-method -->
190
+
191
+
192
+ </div><!-- public-class-method-details -->
193
+
194
+ </div><!-- 5Buntitled-5D -->
195
+
196
+
197
+ </div><!-- documentation -->
198
+
199
+ <div id="validator-badges">
200
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
201
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
202
+ Rdoc Generator</a> 2</small>.</p>
203
+ </div>
204
+
205
+ </body>
206
+ </html>
207
+