Skip to content

Commit

Permalink
Added dont_flatten_patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
bmc committed Jun 16, 2012
1 parent 35812b7 commit f47a435
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rvm ruby-1.9.3-p125@gh-pages
rvm ruby-1.9.3@gh-pages
17 changes: 12 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
---
title: Change Log for Grizzled Rails Logger
layout: default
---

# Change Log

Version 0.1.5

- Changed to work with Rails 3.2.6, while retaining backward compatibility
with prior versions. Addresses [Issue #5][].
- Added a `dont_flatten_patterns` configuration item. See the
[documentation](http://software.clapper.org/grizzled-rails-logger/) for
details.

[Issue #5]: https://github.com/bmc/grizzled-rails-logger/issues/5

---

Version 0.1.4

Before attempting to use (and `gsub` against) the passed-in message, the
Expand Down
36 changes: 27 additions & 9 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ Grizzled::Rails::Logger.configure do |cfg|
cfg.flatten = true
cfg.flatten_patterns = [
/.*/
]
],
cfg.dont_flatten_patterns = [
],
cfg.format = '[%T] (%S) %P %M'
cfg.timeformat = '%Y/%m/%d %H:%M:%S'
cfg.colorize = true
Expand Down Expand Up @@ -173,24 +175,40 @@ If you prefer *not* to flatten log messages, disable the `flatten` setting:
end
{% endhighlight %}

You can also flatten just some of the messages, by specifying flattening
patterns. The default set of flattening patterns flattens all messages with
embedded newlines. However, this strategy can be problematic, in that it'll
also flatten EXPLAIN PLAN output and some exceptions. To control which
messages are flattened, define an array of regular expressions, matched
against each message as if it were already flattened. (That is, the regexps
do _not_ need to take newlines into account.) For example:
You can also flatten just some of the messages, by specifying a combination of
flattening patterns and "don't flatten" patterns. The default set of flattening
patterns flattens all messages with embedded newlines. However, this strategy
can be problematic, in that it'll also flatten EXPLAIN PLAN output and some
exceptions. To control which messages are flattened, define an array of regular
expressions, matched against each message as if it were already flattened.
(That is, the regexps do _not_ need to take newlines into account.) For
example:

{% highlight ruby %}
Grizzled::Rails::Logger.configure do |cfg|
cfg.flatten = false
cfg.flatten_patterns = [
/.*Started GET /,
/.*Started POST /
]
end
{% endhighlight %}

You can exert even more control by defining "don't flatten" patterns, which
take higher priority than "flatten" patterns. For instance, the following
configuration flattens every message *except* those with the words
"EXPLAIN PLAN" in them.

{% highlight ruby %}
Grizzled::Rails::Logger.configure do |cfg|
cfg.flatten_patterns = [
/.*/,
]
cfg.dont_flatten_patterns = [
/\bEXPLAIN\s+PLAN\b/
]
end
{% endhighlight %}

**NOTE: Exception backtraces emitted via `logger.exception()` are *never* flattened.**

## Formatting
Expand Down

0 comments on commit f47a435

Please sign in to comment.