grizzled-rails-logger 0.1.0 → 0.1.1

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.
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Change Log
2
+
3
+ Version 0.1.0
4
+
5
+ * Initial version.
data/README.md CHANGED
@@ -24,167 +24,7 @@ If you want the development version of the gem, use:
24
24
 
25
25
  gem 'grizzled-rails-logger', :git => 'git://github.com/bmc/grizzled-rails-logger.git'
26
26
 
27
- # Configuration
27
+ # Documentation
28
28
 
29
- Becaue *Grizzled Rails Logger* merely adds to the standard Rails logger,
30
- you can continue to all the usual capabilities of the Rails logger (such as,
31
- for instance, tagged logged).
32
-
33
- To configure *Grizzled Rails Logger*, add a section like the following to your
34
- `config/application.rb` file or your individual environment file:
35
-
36
- Grizzled::Rails::Logger.configure do |cfg|
37
- # Configuration data goes here
38
- end
39
-
40
- The default configuration is equivalent to the following:
41
-
42
- Grizzled::Rails::Logger.configure do |cfg|
43
- cfg.flatten = true
44
- cfg.format = '%[T] (%S) %P %M'
45
- cfg.timeformat = '%Y/%m/%d %H:%M:%S'
46
- cfg.colorize = true
47
- cfg.colors = {
48
- :debug => Term::ANSIColor.cyan,
49
- :warn => Term::ANSIColor.yellow + Term::ANSIColor.bold,
50
- :fatal => Term::ANSIColor.red + Term::ANSIColor.bold,
51
- :error => Term::ANSIColor.red
52
- }
53
- end
54
-
55
- Each configuration option is described in more detail, below.
56
-
57
- ## Colorization
58
-
59
- By default, *Grizzled Rails Logger* colorizes logging output, using ANSI
60
- terminal escape sequences (as defined by the [term-ansicolor][] gem).
61
-
62
- You can disable colorization by setting the `colorize` option to `false`:
63
-
64
- Grizzled::Rails::Logger.configure do |cfg|
65
- cfg.colorize = false
66
- end
67
-
68
- You can also change the colors associated with each severity. Suppose, for
69
- instance, that you want INFO messages (which normally aren't colorized) to be
70
- white, and you wanted DEBUG messages (which are normally cyan) to be bold blue.
71
- You'd simply reconfigure those values, as shown below:
72
-
73
- Grizzled::Rails::Logger.configure do |cfg|
74
- cfg.colors[:debug] = Term::ANSIColor.bold + Term::ANSIColor.blue
75
- cfg.colors[:info] = Term::ANSIColor.white
76
- end
77
-
78
- `Term::ANSIColor` is automatically included for you.
79
-
80
- **WARNING:** *Grizzled Rails Logger* does not verify that the values you
81
- store in the color settings are legal ANSI sequences. The following is
82
- perfectly legal, though probably not what you want:
83
-
84
- Grizzled::Rails::Logger.configure do |cfg|
85
- cfg.colors[:debug] = "red"
86
- end
87
-
88
- With that setting, a debug message that normally looks like this:
89
-
90
- [2012/04/12 14:43:22] (DEBUG) 9816 My debug message
91
-
92
- will, instead, look like this:
93
-
94
- red[2012/04/12 14:43:22] (DEBUG) 9816 My debug message
95
-
96
- ## Exception logging
97
-
98
- *Grizzled Rails Logger* adds an `exception()` method, providing an easy way
99
- to dump a rescued exception and its backtrace:
100
-
101
- begin
102
- # Some dangerous operation
103
- rescue Exception => ex
104
- logger.exception("Error while doing dangerous thing", ex)
105
- end
106
-
107
- The method takes three parameters, one of which is optional:
108
-
109
- * `message` - a message to be displayed along with the exception. Can be nil,
110
- but must be supplied.
111
- * `exception` - the exception to be dumped.
112
- * `progname` - program name. Optional; defaults to nil.
113
-
114
- The exception is dumped at severity level ERROR.
115
-
116
- Regardless of the setting of `flatten` (see below), the exception's backtrace
117
- is always displayed on multiple lines.
118
-
119
- ## Flattening
120
-
121
- The default Rails logger includes lots of newlines in its log messages. For
122
- example:
123
-
124
- [2012/04/12 14:59:48] (INFO) 10102 [659d08c8cbcf3ddf543ca3710cee2771]
125
-
126
- Started GET "/about" for 127.0.0.1 at 2012-04-12 14:59:48 -0400
127
-
128
- *Grizzled Rails Logger* automatically flattens log messages to a single line:
129
-
130
- [2012/04/12 14:59:48] (INFO) 10102 [659d08c8cbcf3ddf543ca3710cee2771] Started GET "/about" for 127.0.0.1 at 2012-04-12 14:59:48 -0400
131
-
132
- If you prefer *not* to flatten log messages, disable the `flatten` setting:
133
-
134
- Grizzled::Rails::Logger.configure do |cfg|
135
- cfg.flatten = false
136
- end
137
-
138
- **NOTE:** Exception backtraces are *never* flattened.
139
-
140
- ## Formatting
141
-
142
- Two settings control formatting.
143
-
144
- ### Message format
145
-
146
- The `format` setting controls overall message formatting. Four escape
147
- sequences control how the message is assembled:
148
-
149
- * `%T` - Any "%T" sequences in the format are replaced by the current time.
150
- The format of the time is controlled by `timeformat` (see below).
151
- * `%P` - Any "%P" sequences are replaced with the process ID of the Rails
152
- instance that's emitting the message.
153
- * `%S` - Any "%S" sequences are replaced with an upper case string
154
- representation of the message's severity (e.g., "ERROR", "WARN").
155
- * `%M` - Any "%M" sequences are replaced by the message, including any
156
- tags inserted via tagged logging.
157
-
158
- Any other characters, including blanks, are emitted verbatim.
159
-
160
- It's legal (but probably silly) to include a sequence multiple times. If you
161
- don't want a specific value to be logged, simply omit its escape sequence
162
- from the format.
163
-
164
- The default format is: `[%T] (%S) %P %M`.
165
-
166
- For example, to change the log format to omit the PID, use:
167
-
168
- Grizzled::Rails::Logger.configure do |cfg|
169
- cfg.format = '[%T] (%S) %M'
170
- end
171
-
172
-
173
- ### Time format
174
-
175
- The `timeformat` setting controls how the current time (see "%T", above) is
176
- formatted. `timeformat` is a [strftime][] format string.
177
-
178
- The default time format is: `%Y/%m/%d %H:%M:%S`
179
-
180
- # Alternatives
181
-
182
- Alternatives to this gem include:
183
-
184
- * Paul Dowman's [better_logging][] gem
185
- * [itslog][]
186
-
187
- [better_logging]: https://github.com/pauldowman/better_logging
188
- [itslog]: https://github.com/johnnytommy/itslog
189
- [term-ansicolor]: https://github.com/flori/term-ansicolor
190
- [strftime]: http://strftime.net/
29
+ Complete documentation for this software is available on the
30
+ [home page](http://software.clapper.org/grizzled-rails-logger/)
data/Rakefile CHANGED
@@ -86,14 +86,14 @@ task :pubrdoc => :doc do |t|
86
86
  end
87
87
 
88
88
  desc "Synonym for 'pubchangelog'"
89
- task :changelog
89
+ task :changelog => :pubchangelog
90
90
 
91
91
  desc "Publish the change log. Not really of use to anyone but the author"
92
92
  task :pubchangelog do |t|
93
93
  File.open(File.join(GH_PAGES_DIR, 'CHANGELOG.md'), 'w') do |f|
94
94
  f.write <<EOF
95
95
  ---
96
- title: Change Log for Grizzled Ruby
96
+ title: Change Log for Grizzled Rails Logger
97
97
  layout: default
98
98
  ---
99
99
 
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'grizzled-rails-logger'
4
- s.version = '0.1.0'
5
- s.date = '2012-04-12'
4
+ s.version = '0.1.1'
5
+ s.date = '2012-04-19'
6
6
  s.summary = 'A custom Rails 3 logger'
7
7
  s.authors = ['Brian M. Clapper']
8
8
  s.license = 'BSD'
@@ -17,15 +17,18 @@ module Grizzled # :nodoc:
17
17
 
18
18
  # Configuration constants
19
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
20
+ flatten: true,
21
+ flatten_patterns: [
22
+ /.*/
23
+ ],
24
+ format: '[%T] (%S) %P %M',
25
+ timeformat: '%Y/%m/%d %H:%M:%S',
26
+ colorize: true,
27
+ colors: {
28
+ debug: Term::ANSIColor.cyan,
29
+ warn: Term::ANSIColor.yellow + Term::ANSIColor.bold,
30
+ fatal: Term::ANSIColor.red + Term::ANSIColor.bold,
31
+ error: Term::ANSIColor.red
29
32
  }
30
33
  )
31
34
 
@@ -97,7 +100,20 @@ module Grizzled # :nodoc:
97
100
  end
98
101
 
99
102
  flatten = options.fetch(:flatten, Configuration.flatten)
100
- message.gsub!("\n", '') if flatten
103
+ if flatten
104
+ patterns = options.fetch(
105
+ :flatten_patterns, Configuration.flatten_patterns
106
+ )
107
+ patterns = ['.*'] if patterns.nil? || (patterns.length == 0)
108
+ flattened_message = message.gsub("\n", '')
109
+ patterns.each do |pattern|
110
+ if pattern =~ flattened_message
111
+ message = flattened_message
112
+ break
113
+ end
114
+ end
115
+ end
116
+
101
117
  time = Time.now.strftime(Configuration.timeformat)
102
118
  pid = $$.to_s
103
119
  sev = SEVERITIES[severity].to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grizzled-rails-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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-04-12 00:00:00.000000000 Z
12
+ date: 2012-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: term-ansicolor
16
- requirement: &9680860 !ruby/object:Gem::Requirement
16
+ requirement: &21606220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.0.7
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *9680860
24
+ version_requirements: *21606220
25
25
  description: ! 'A custom Rails 3 logger
26
26
 
27
27
  '
@@ -32,6 +32,7 @@ extra_rdoc_files: []
32
32
  files:
33
33
  - README.md
34
34
  - LICENSE.md
35
+ - CHANGELOG.md
35
36
  - Rakefile
36
37
  - grizzled-rails-logger.gemspec
37
38
  - lib/grizzled/rails.rb