CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Log Book

  1. #1
    Join Date
    Feb 2003
    Location
    Israel
    Posts
    40

    Log Book

    How can I make a class for writing to Log text file.

    I need to Initialize it in the beginning of the program and close it.

    every time I call the Write sub of the class I need to open and close it...

    not open it in the beginning and close it in the end.

  2. #2
    Join Date
    May 2002
    Location
    Toronto
    Posts
    167
    The simplest way to do it is set up Global variables

    FN as String 'Make that string = "c:\directory\filename"

    then when you want to open and close it you just use FN

    FP as Integer 'depending on the type of file you are going to use, you can do something like that to remember the last write position to the file

  3. #3
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167
    This is when multi-threading comes in handy. Make you LOG class work on a seperate thread that reads from a queue (this should be synchronized queue) and the thread should run at a specific interval.

    The idea is to have a global queue where your app can dump the log text into and your worker thread will get data from the queue and append it into a file.

    -Cool Bizs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured