From: Karl Gabel Date: 2007-03-16T17:14:19+09:00 Subject: Re: A little advice on writing a logWriter Alex Hedin schrieb: > Hello! > > What I want do do is to make a logwriter so I can store the > information that comes in from a given network. For example I would > like to see what kind of data I'm receiving from that network by > having this logwriter storing that info for me. there is doc for the socket class, this is much easier to write the whole stuff then in C http://www.ruby-doc.org/stdlib/libdoc/socket/rdoc/index.html maybe this is interessting for you http://www.ruby-doc.org/stdlib/libdoc/drb/rdoc/index.html http://www.chadfowler.com/ruby/drb.html > > I went and looked at this link: (http://log4r.sourceforge.net) > > But that is a completely done written logging program right? What I > would want do to, is to write one of my own. I thought they were > simpler than that.... CAn you give mne advice on how to proceed? > log_fd = File.new("test_log", "w+") > or just open an existing one > > log_fd.write(str) > or > log_fd << "str" > log_fd.flush > > This for sure is of great help. The File class seem very handy, jsut > that its my first logwriter and I don't exactly know wot the main > components should be (apart from write and read methods) in my > logwriter... > > I don't know either, I am sorry. I never write a logwriter before, I just logged some messages with the classes above (socket and DRb). regards karl > Any advice is highly welcome and appreciated. > > Cheers, > > > Alex > > > > > On 3/15/07, Karl Gabel wrote: >> Alexander Jonsson schrieb: >> > Hello everyone, >> > >> > I'm new to Ruby and not so experienced programmer in overall but i >> > manage to do "ok". Now I started to program a bit in Ruby and wanted >> > to write a logWriter program but the problem is that Ruby doesnt have >> > I/O Stream functions like java and C++. >> > >> log_fd = File.new("test_log", "w+") >> or just open an existing one >> >> log_fd.write(str) >> or >> log_fd << "str" >> log_fd.flush >> >> you can also use sprintf >> >> log_fd.write(sprintf "%d", var) >> >> log_fd.close >> >> have a look to >> http://www.ruby-doc.org/core/classes/IO.html >> >> is this you are looking for? >> >> regards >> >> karl >> >> >