aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/debugging_rails_applications.textile
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2012-09-09 17:38:47 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2012-09-09 17:38:47 +0530
commitcb524dc1d7525a26ecea8cf049757e530f0d4026 (patch)
tree3a2d8727e97c67e37a357c1cf180e9ca17cff28b /guides/source/debugging_rails_applications.textile
parent6107407e66aa68cf269ec00b64d7ab3623465b97 (diff)
parent2db79dc9ea0b623c6d76b72e85f58efd63b50e08 (diff)
downloadrails-cb524dc1d7525a26ecea8cf049757e530f0d4026.tar.gz
rails-cb524dc1d7525a26ecea8cf049757e530f0d4026.tar.bz2
rails-cb524dc1d7525a26ecea8cf049757e530f0d4026.zip
Merge branch 'master' of github.com:lifo/docrails
Conflicts: activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
Diffstat (limited to 'guides/source/debugging_rails_applications.textile')
-rw-r--r--guides/source/debugging_rails_applications.textile11
1 files changed, 11 insertions, 0 deletions
diff --git a/guides/source/debugging_rails_applications.textile b/guides/source/debugging_rails_applications.textile
index 667f2d2140..a5a22a8a8f 100644
--- a/guides/source/debugging_rails_applications.textile
+++ b/guides/source/debugging_rails_applications.textile
@@ -191,6 +191,17 @@ Completed in 0.01224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localh
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 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 = 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>
+
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.