aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/debugging_rails_applications.textile
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2012-09-09 17:25:09 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2012-09-09 17:25:44 +0530
commit2db79dc9ea0b623c6d76b72e85f58efd63b50e08 (patch)
tree2db0a614b9f03c7c95ec0495f20ac0e5e506d981 /guides/source/debugging_rails_applications.textile
parentdecf4a164d2b00f0be3fc8331df0f0cbe16e7e94 (diff)
downloadrails-2db79dc9ea0b623c6d76b72e85f58efd63b50e08.tar.gz
rails-2db79dc9ea0b623c6d76b72e85f58efd63b50e08.tar.bz2
rails-2db79dc9ea0b623c6d76b72e85f58efd63b50e08.zip
minor fixes and edits [ci skip]
Diffstat (limited to 'guides/source/debugging_rails_applications.textile')
-rw-r--r--guides/source/debugging_rails_applications.textile21
1 files changed, 8 insertions, 13 deletions
diff --git a/guides/source/debugging_rails_applications.textile b/guides/source/debugging_rails_applications.textile
index 99430e1e5f..a5a22a8a8f 100644
--- a/guides/source/debugging_rails_applications.textile
+++ b/guides/source/debugging_rails_applications.textile
@@ -189,24 +189,19 @@ Redirected to #<Post:0x20af760>
Completed in 0.01224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localhost/posts]
</shell>
+Adding extra logging like this makes it easy to search for unexpected or unusual behavior in your logs. If you add extra logging, be sure to make sensible use of log levels, to avoid filling your production logs with useless trivia.
+
h4. Tagged Logging
-When running a multi-user, multi-account application, it’s a great help to be able to filter the log by who did what. TaggedLogging in Active Support helps in doing exactly that by stamping log lines with subdomains, request ids, and anything else to aid debugging such applications.
+When running multi-user, multi-account applications, it’s often useful to be able to filter the logs using some custom rules. +TaggedLogging+ in Active Support helps in doing exactly that by stamping log lines with subdomains, request ids, and anything else to aid debugging such applications.
+
<ruby>
-logger.tagged("custom_tag") { logger.info "Date is #{Time.now.to_date}" }
-logger.tagged("custom_tag", "gaurish") { logger.info "multiple tags are supported" }
+logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
+logger.tagged("BCX") { logger.info "Stuff" } # Logs "[BCX] Stuff"
+logger.tagged("BCX", "Jason") { logger.info "Stuff" } # Logs "[BCX] [Jason] Stuff"
+logger.tagged("BCX") { logger.tagged("Jason") { logger.info "Stuff" } } # Logs "[BCX] [Jason] Stuff"
</ruby>
-Now, you filter logs by searching for +custom_tag+ & logs with tag +custom_tag+ would be returned. Here's an example using <tt>grep</tt> command
-<shell>
- $ grep custom_tag log/development.log
-[custom_tag] Date is 2012-09-03
-[custom_tag] [gaurish] multiple tags are supported
-</shell>
-Tagged Logging makes it easier to filter logs & exact selected lines only. For more details and examples, check the API documentation, see "<tt>TaggedLogging</tt>":http://api.rubyonrails.org/classes/ActiveSupport/TaggedLogging.html
-
-Adding extra logging like this makes it easy to search for unexpected or unusual behavior in your logs. If you add extra logging, be sure to make sensible use of log levels, to avoid filling your production logs with useless trivia.
-
h3. Debugging with the +debugger+ gem
When your code is behaving in unexpected ways, you can try printing to logs or the console to diagnose the problem. Unfortunately, there are times when this sort of error tracking is not effective in finding the root cause of a problem. When you actually need to journey into your running source code, the debugger is your best companion.