Re: Design question...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Michael C wrote:

"Nick Z." <pacemkr@xxxxxxxxx> wrote in message news:OO0_e.103$Ge5.70@xxxxxxxxxxx

I am writing a reusable class for logging.
My goal is to make it as fast and as robust as possible, while keeping memory usage to the lowest. All members are static.


For some reason I'm stuck on the following design question.
Obviously you need a stream to write the log file.
Should this stream be created every time the log needs to be written, or should the stream be a member variable of the logging class and only be opened and closed once per application lifetime.


Can someone suggest the right way to go here and why?
This seems like a simple question but for some reason I can't decide which is the right way to do this. Does it even matter?


For logs I open and close the stream each time. If someone happens to terminate the app premeturely you need to be able to see the log.

Michael



Hmmm, true. But what if you force the stream to flush after each write.
I guess I want to know what the overhead is for creating the stream every time.
.




Relevant Pages

  • Re: Working on ARC4-16 bit
    ... > size of the state array, the problem is the quality of the output stream. ... Well, it may be true if ARC4 was a rng, but like all algorithm it's ... ARC4-8 is not actually considered good for HD or othr cumbersome data ... reason that made me post here for help. ...
    (sci.crypt)
  • Re: Greek Fire
    ... The reason is that the properties are contradictory. ... the stream of liquid. ... It ignites at one end. ... reasonably sized queue outside the funding office... ...
    (soc.history.medieval)
  • Re: Greek Fire
    ... The reason is that the properties are contradictory. ... the stream of liquid. ... It ignites at one end. ... reasonably sized queue outside the funding office... ...
    (soc.history.medieval)
  • Re: Binary serialization
    ... Previously I would use a file write routine that worked ... DATA members from the class in question the method of writing each ... the base class where you collect the data in to a byte array which is ... then written to the stream by the base class. ...
    (microsoft.public.dotnet.general)
  • Re: Greek Fire
    ... The reason is that the properties are contradictory. ... but which bursts into flame as soon as it ... the stream of liquid. ... It ignites at one end. ...
    (soc.history.medieval)