Permalink
Browse files

WIP: Logger replacement for Rails.

Adds tags to the end of the log string, without brackets.
  • Loading branch information...
roidrage committed Sep 17, 2012
1 parent 578dcdc commit d570648c0aad9a82cc4b94a742d97667d7981f16
Showing with 15 additions and 0 deletions.
  1. +15 −0 lib/lograge/logger.rb
View
@@ -0,0 +1,15 @@
+require 'active_support/tagged_logging'
+
+class Lograge::Logger < ActiveSupport::TaggedLogging
+ def add(severity, message = nil, progname = nil, &block)
+ message = (block_given? ? block.call : progname) if message.nil?
+ @logger.add(severity, "#{message} #{tags_as_pairs}", progname)
+ end
+
+ def tags_as_pairs
+ tags = current_tags
+ if tags.any?
+ tags.collect {|tag| tag}.join(" ")
+ end
+ end
+end

0 comments on commit d570648

Please sign in to comment.