Open surenm opened 12 years ago
These are just warning anyways and the library works as such.
Same issue here. Cool library but it's an annoyance.
Try the new branch refactor. I'm trying to remove all those "nasty constants" and turn them into class methods. See how it works and go from there... Cheers!
Thanks for the suggestion! Here's what I got when referencing that branch in my gemfile. I didn't make any changes to my code.
uninitialized constant Log4r::Logger::LoggerFactory::OFF
/Users/noah/.bundler/ruby/1.9.1/log4r-color-808e0368666b/lib/log4r-color/loggerfactory.rb:18:in `define_methods'
/Users/noah/.bundler/ruby/1.9.1/log4r-color-808e0368666b/lib/log4r-color/logger.rb:37:in `initialize'
/Users/noah/Projects/service/config/environments/development.rb:46:in `new'
/Users/noah/Projects/service/config/environments/development.rb:46:in `block in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:24:in `class_eval'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:24:in `configure'
/Users/noah/Projects/service/config/environments/development.rb:8:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/engine.rb:571:in `block in <class:Engine>'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/noah/Projects/service/config/environment.rb:8:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/application.rb:103:in `require_environment!'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
/usr/local/rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => task:name => environment
(See full trace by running task with --trace)
Here's where I setup Log4r in development.rb:
require 'log4r-color'
require 'log4r/formatter/log4jxmlformatter'
require 'log4r/outputter/udpoutputter'
require 'log4r/staticlogger'
require 'log4r/outputter/consoleoutputters'
include Log4r
Later on in development.rb
# Log4r
config.logger = Log4r::Logger.new("Application Log")
config.logger.level = Log4r::INFO
config.logger.trace = true
udpout = Log4r::UDPOutputter.new 'udpOutputter', {:name => "localhost", :port => 877}
udpout.formatter = Log4r::Log4jXmlFormatter.new
pattern_formatter = Log4r::PatternFormatter.new(:pattern => "[%l] %d :: %M => %t")
file = Log4r::FileOutputter.new('fileOutputter', { :filename => './log/development.log', :trunc => false } )
file.formatter = pattern_formatter
stdout = Log4r::StdoutOutputter.new 'consoleStdOutputter'
stdout.formatter = pattern_formatter
color = ColorOutputter.new 'color', {
:colors =>
{
:debug => :gray,
:info => { color: :light_blue, background: :green},
:warn => :yellow,
:error => :red,
:fatal => {:color => :red, :background => :white}
}
}
config.logger.outputters = [udpout, file, color]
Hey, I only just started refactoring. I haven't even tested my changes yet. You are most welcome to help in the effort. The key is to remove all those nasty constants and turn them into class methods.
Log4r::INFO
, Log4r::OFF
and similar will be no more... (IMO)
I haven't touched loggerfactory.rb
, so please look into it and debug accordingly. You should be able to see a diff of my changes on my latest commit, see where I'm heading and go from there. Good luck ;)
The key is to not touch the current functionality, only refactor the infrastructure.
Oh okay, didn't realize you just started ;-)
I'm only a few months into Ruby so I may not be a huge help, but I'll take a look.
On Wed, Aug 28, 2013 at 9:30 AM, Kristian Mandrup notifications@github.comwrote:
Hey, I only just started refactoring. I haven't even tested my changes yet. You are most welcome to help in the effort. The key is to remove all those nasty constants and turn them into class methods.
Log4r::INFO, Log4r::OFF and similar will be no more... (IMO)
I haven't touched loggerfactory.rb, so please look into it and debug accordingly. You should be able to see a diff of my changes on my latest commit, see where I'm heading and go from there. Good luck ;) The key is to not touch the current functionality, only refactor the infrastructure.
— Reply to this email directly or view it on GitHubhttps://github.com/kristianmandrup/log4r-color/issues/2#issuecomment-23428549 .
Haha :) I think this was the first gem I worked on, also as a newbie Rubyist. Since then I have created hundreds of gems... good practice!
Hi kristianmandrup,
Thanks for an excellent library. Really simple and extremely useful.
I use it with rails for logging my backend scripts and when I start console, it throws the following issues. Thought I should report it just in case.
Rails 3.2.0 and Ruby 1.9.2