[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

A little advice on writing a logWriter

Alexander Jonsson

3/15/2007 3:59:00 PM

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++.

I have never written a simple log writer before either, this will be
challenging. Is there any advice on how to proceed you could give a
fellow rookie ruby lover? :)


Cheers,

RubyNub

12 Answers

Vlad Galu

3/15/2007 4:09:00 PM

0

On 3/15/07, Alexander Jonsson <imonmedicine@gmail.com> wrote:
> 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++.

Instead it has a quite capable File class.

> I have never written a simple log writer before either, this will be
> challenging. Is there any advice on how to proceed you could give a
> fellow rookie ruby lover? :)

Take a look at log4r (http://log4r.sourc...). It aims to
resemble log4j/log4cpp as much as possible.

>
>
> Cheers,
>
> RubyNub
>
>


--
If it's there, and you can see it, it's real.
If it's not there, and you can see it, it's virtual.
If it's there, and you can't see it, it's transparent.
If it's not there, and you can't see it, you erased it.

Karl Gabel

3/15/2007 4:31:00 PM

0

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/class...

is this you are looking for?

regards

karl

Alexander Jonsson

3/15/2007 5:21:00 PM

0

Thanks Vlad, I will take a look at it right now.


> > 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++.
>
> Instead it has a quite capable File class.
>
> > I have never written a simple log writer before either, this will be
> > challenging. Is there any advice on how to proceed you could give a
> > fellow rookie ruby lover? :)
>
> Take a look at log4r (http://log4r.sourc...). It aims to
> resemble log4j/log4cpp as much as possible.
>
> >
> >
> > Cheers,
> >
> > RubyNub
> >
> >
>
>
> --
> If it's there, and you can see it, it's real.
> If it's not there, and you can see it, it's virtual.
> If it's there, and you can't see it, it's transparent.
> If it's not there, and you can't see it, you erased it.
>
>

Kyle Schmitt

3/15/2007 5:40:00 PM

0

Ooh. From personal experience log4r is rather poorly documented (in
bad moods I'd call it abysmal, but right now, I'll just say poor). If
you have trouble, just post it here and folks who've used it will
help.

I'm trying to find the script I had that used it extensively to show
another example, but it may have gotten purged...

--Kyle

James Gray

3/15/2007 7:23:00 PM

0

On Mar 15, 2007, at 12:39 PM, Kyle Schmitt wrote:

> Ooh. From personal experience log4r is rather poorly documented (in
> bad moods I'd call it abysmal, but right now, I'll just say poor). If
> you have trouble, just post it here and folks who've used it will
> help.

You could read the standard logger library which is pretty easy to
follow.

James Edward Gray II

Karl Gabel

3/16/2007 8:14:00 AM

0

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/...

maybe this is interessting for you
http://www.ruby-doc.org/stdlib/libdoc/drb/rdoc/...
http://www.chadfowler.com/rub...
>
> I went and looked at this link: (http://log4r.sourc...)
>
> 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 <kaguga@gmx.de> 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/class...
>>
>> is this you are looking for?
>>
>> regards
>>
>> karl
>>
>>
>


maybeiam101

11/15/2008 4:27:00 AM

0


> -----------------------------------------------------------------------
> I don't deny people are changing wikipidia articles to suit their political
> advantage but when you want to be able to say forced female mutilation is a
> good thing then there is something seriously wrong with your mental state.
> It is an evil practice, end of story.

C'mon. You can do better than that. Equivocating a person's criticism
of an organisation with support for the things it opposes is the
oldest trick in the book. The most basic tool of smear there is. But
I'm sure you know that. Now, about that evidence.

moslem cartoon character mohammad the koos was a goat fucking child molesting POS

11/15/2008 7:49:00 AM

0

On Nov 15, 2:49 pm, "Seon Ferguson" <seo...@gmail.com> wrote:
> <maybeiam...@gmail.com> wrote in message
>
> news:aa349142-3d5d-4460-b672-0383a34b12f1@40g2000prx.googlegroups.com...
>
>
>
> >> -----------------------------------------------------------------------
> >> I don't deny people are changing wikipidia articles to suit their
> >> political
> >> advantage but when you want to be able to say forced female mutilation is
> >> a
> >> good thing then there is something seriously wrong with your mental
> >> state.
> >> It is an evil practice, end of story.
>
> > C'mon. You can do better than that. Equivocating a person's criticism
> > of an organisation with support for the things it opposes is the
> > oldest trick in the book. The most basic tool of smear there is. But
> > I'm sure you know that. Now, about that evidence.
>
> Um I said he's right about Wikipedia...

How is it that every time there is a *real* story on these boards,
suddenly you are wheeled out on que?!

W

PaulHammond

11/15/2008 12:39:00 PM

0

On 15 Nov, 04:26, maybeiam...@gmail.com wrote:
> > -----------------------------------------------------------------------
> > I don't deny people are changing wikipidia articles to suit their political
> > advantage but when you want to be able to say forced female mutilation is a
> > good thing then there is something seriously wrong with your mental state.
> > It is an evil practice, end of story.
>
> C'mon. You can do better than that. Equivocating a person's criticism
> of an organisation with support for the things it opposes is the
> oldest trick in the book. The most basic tool of smear there is. But
> I'm sure you know that. Now, about that evidence.

So, maybeiam101, I've got a couple of questions to pose to you.

1) What's your beef with the Tahirih Justice Centre

2) How do you know what kind of women Nima likes?

Paul

maybeiam101

11/16/2008 3:28:00 AM

0

On Nov 15, 10:38 pm, PaulHammond <pahamm...@onetel.net.uk> wrote:
> On 15 Nov, 04:26, maybeiam...@gmail.com wrote:

> So, maybeiam101, I've got a couple of questions to pose to you.
>
> 1)  What's your beef with the Tahirih Justice Centre

Very simple. That TJC professes principles that appear as appealing to
higher moral values, yet acts in a duplicitous (and quite possibly
illegal) manner, exactly in keeping with the behaviour of the rest of
the Bahai orgnaisation.

> 2) How do you know what kind of women Nima likes?

What, you don't have any relationships where you know this about
another person? Please.