Class: Yarder::Logger
Overview
Based on the ActiveSupport::Logger (Formerly known as BufferedLogger)
Defined Under Namespace
Classes: SimpleFormatter
Instance Attribute Summary collapse
-
#log_namespace ⇒ Object
Returns the value of attribute log_namespace.
-
#log_type ⇒ Object
Returns the value of attribute log_type.
Class Method Summary collapse
-
.broadcast(logger) ⇒ Object
Broadcasts logs to multiple loggers.
Instance Method Summary collapse
- #env ⇒ Object
-
#initialize(*args) ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
#initialize(*args) ⇒ Logger
Returns a new instance of Logger.
45 46 47 48 49 50 |
# File 'lib/yarder/logger.rb', line 45 def initialize(*args) super self.log_type = :rails_json_log self.log_namespace = :rails @formatter = SimpleFormatter.new end |
Instance Attribute Details
#log_namespace ⇒ Object
Returns the value of attribute log_namespace.
43 44 45 |
# File 'lib/yarder/logger.rb', line 43 def log_namespace @log_namespace end |
#log_type ⇒ Object
Returns the value of attribute log_type.
43 44 45 |
# File 'lib/yarder/logger.rb', line 43 def log_type @log_type end |
Class Method Details
.broadcast(logger) ⇒ Object
Broadcasts logs to multiple loggers.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/yarder/logger.rb', line 9 def self.broadcast(logger) # :nodoc: Module.new do define_method(:add) do |*args, &block| logger.add(*args, &block) super(*args, &block) end define_method(:<<) do |x| logger << x super(x) end define_method(:close) do logger.close super() end define_method(:progname=) do |name| logger.progname = name super(name) end define_method(:formatter=) do |formatter| logger.formatter = formatter super(formatter) end define_method(:level=) do |level| logger.level = level super(level) end end end |
Instance Method Details
#env ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/yarder/logger.rb', line 52 def env @env ||= { :ruby => "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}", :env => Rails.env, :pwd => Dir.pwd, :program => $0, :user => ENV['USER'], :host => ::Socket.gethostname } end |