Ruby-net-nntp usage

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

puts “host…”

puts nntp

puts nntp.connect

thufir@dur:~/ruby/nntp$
thufir@dur:~/ruby/nntp$ gem list --local | grep nntp
ruby-net-nntp (1.0.0)
thufir@dur:~/ruby/nntp$
thufir@dur:~/ruby/nntp$ gem --version
1.8.19
thufir@dur:~/ruby/nntp$
thufir@dur:~/ruby/nntp$ ruby --version
ruby 1.9.3p125 (2012-02-16 revision 34643) [i686-linux]
thufir@dur:~/ruby/nntp$
thufir@dur:~/ruby/nntp$ rvm --version

rvm 1.10.3 by Wayne E. Seguin [email protected], Michal P.
[email protected] [https://rvm.beginrescueend.com/]

thufir@dur:~/ruby/nntp$

thanks,

Thufir

Thufir wrote in post #1053185:

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:

nntp.logger = Logger.new ‘mylog’

before calling nntp.connect.

HTH,

  • Lars

[1]
https://forge.secure.at:10443/hgweb/projects/ruby-net-nntp/file/c3318cb0b5af/lib/net/nntp.rb

On Tue, 27 Mar 2012 18:21:30 +0900, Lars Mai wrote:

From the sources [1] it seems that you have to initialize the logger
manually. Try adding something like:

nntp.logger = Logger.new ‘mylog’

before calling nntp.connect.

Thanks, I looked at the source, and installed log4r, and looked at their
webpage as well. I’ve tried variations, but get:

thufir@dur:~/ruby/nntp$
thufir@dur:~/ruby/nntp$ nl nntp.rb
1 require ‘rubygems’
2 require ‘net/nntp’

 3  nntp = Net::NNTP.new
 4  Net::NNTP.logger = Logger.new
 5  welcome = nntp.connect

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$

thanks,

Thufir

THUFIR H. wrote in post #1053580:

Thanks, I looked at the source, and installed log4r, and looked at their
webpage as well. I’ve tried variations, but get:

thufir@dur:~/ruby/nntp$
thufir@dur:~/ruby/nntp$ nl nntp.rb
1 require ‘rubygems’
2 require ‘net/nntp’

 3  nntp = Net::NNTP.new
 4  Net::NNTP.logger = Logger.new
 5  welcome = nntp.connect

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:

Net::NNTP.logger = Log4r::Logger.new ‘mylog’

HTH,

  • Lars

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:

#Net::NNTP.logger = Logger.new
Net::NNTP.logger = Log4r::Logger.new ‘mylog’

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