am I not using the correct requires info? So far as I can tell, I’ve
followed the example code, with the proviso that they seem to mean
“host”
to replace “server”.
The first warning, about iconv, applies to the net/nntp gem?
The NameError is also within the gem itself?
thufir@dur:~/ruby/nntp$
thufir@dur:~/ruby/nntp$ ruby nntp.rb
/home/thufir/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/
rubygems/custom_require.rb:36:in require': iconv will be deprecated in the future, use String#encode instead. nntp.. host... #<Net::NNTP:0x90d66ec> /home/thufir/.rvm/gems/ruby-1.9.3-p125/gems/ruby-net-nntp-1.0.0/lib/net/ nntp.rb:30:in logger’: uninitialized class variable @@logger in
Net::NNTP
(NameError)
from /home/thufir/.rvm/gems/ruby-1.9.3-p125/gems/ruby-net-
nntp-1.0.0/lib/net/nntp.rb:35:in debug' from /home/thufir/.rvm/gems/ruby-1.9.3-p125/gems/ruby-net- nntp-1.0.0/lib/net/nntp.rb:95:in read_response’
from /home/thufir/.rvm/gems/ruby-1.9.3-p125/gems/ruby-net-
nntp-1.0.0/lib/net/nntp.rb:73:in connect' from nntp.rb:14:in ’
thufir@dur:~/ruby/nntp$
thufir@dur:~/ruby/nntp$ cat nntp.rb
require ‘rubygems’
require ‘net/nntp’
puts “nntp…”
nntp = Net::NNTP.new
nntp.host = ‘localhost’ # also default
nntp.port = 119 # default port
am I not using the correct requires info? So far as I can tell, I’ve
followed the example code, with the proviso that they seem to mean
“host”
to replace “server”.
Your problem seems to be related to the logging output:
/home/thufir/.rvm/gems/ruby-1.9.3-p125/gems/ruby-net-nntp-1.0.0/lib/net/
nntp.rb:30:in logger': uninitialized class variable @@logger in Net::NNTP (NameError) from /home/thufir/.rvm/gems/ruby-1.9.3-p125/gems/ruby-net- nntp-1.0.0/lib/net/nntp.rb:35:in debug’
from /home/thufir/.rvm/gems/ruby-1.9.3-p125/gems/ruby-net-
nntp-1.0.0/lib/net/nntp.rb:95:in read_response' from /home/thufir/.rvm/gems/ruby-1.9.3-p125/gems/ruby-net- nntp-1.0.0/lib/net/nntp.rb:73:in connect’
from nntp.rb:14:in `’
From the sources [1] it seems that you have to initialize the logger
manually. Try adding something like:
thufir@dur:~/ruby/nntp$
thufir@dur:~/ruby/nntp$ ruby nntp.rb
/home/thufir/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/
rubygems/custom_require.rb:36:in require': iconv will be deprecated in the future, use String#encode instead. nntp.rb:5:in': uninitialized constant Logger (NameError)
thufir@dur:~/ruby/nntp$
thufir@dur:~/ruby/nntp$
thufir@dur:~/ruby/nntp$ ruby nntp.rb
/home/thufir/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/
rubygems/custom_require.rb:36:in require': iconv will be deprecated in the future, use String#encode instead. nntp.rb:5:in': uninitialized constant Logger (NameError)
Oops. Just in case you haven’t figured it out yourself by now: you need
to initialize the log4r logger with the full namespace, like this:
On Fri, 30 Mar 2012 21:39:14 +0900, Lars Mai wrote:
[…]
Oops. Just in case you haven’t figured it out yourself by now: you need
to initialize the log4r logger with the full namespace, like this:
Net::NNTP.logger = Log4r::Logger.new ‘mylog’
[…]
LOL, thanks Lars. I kid you not, I just now kludged together something
with JDBC:
checked my gmane lists, and saw your post! I can now have parallel
projects, heh. Anyhow, yeah, I sorta see.
The warning from the gem:
/home/thufir/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/
rubygems/custom_require.rb:36:in `require’: iconv will be deprecated in
the future, use String#encode instead.
isn’t a big deal, right?
More significantly, I’m not really clear on the difference between:
I mean, are they both on the same Logger class? I would think so, that
you wouldn’t want two Logger classes, that sounds like a bad idea. So,
why do you need to fully specify the class? Shouldn’t ruby know,
somehow, which Logger I mean?
thanks again,
Thufir
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.