Thread: IRC-type logger with files based on three values

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    16

    IRC-type logger with files based on three values

    I'm starting to write an app that is similar to an IRC logger. Each log file will be based on three values or so -- user name, IP, and channel. The reason I have both user name and IP is so that I can keep track of what user names an IP uses or vice versa. I need the channel so the bot will be in multiple channels. I may add more values for each unique log file in the future.

    For example, there will be 2 log files generated for user Foo, IP 123.123.123.123, channel 123 and for Foo, IP 123.123.123.123, channel 234.

    What is an efficient way to generate a log file for each of these values? I thought about this for a while and all I can think of is to create a text file with three columns (one for each value) and every time the user talks, I check this text file and put their conversation in the appropriate log file. This requires file access every talk though, so it is not scalable.

    Alternatively, I could just log everything in a single file and have another C app that splits up the conversation based on these three values. I'd like to implement both and see how major of a performance difference this is, but if you have more efficient ways, I'd love any feedback.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Surely you could have a table in memory that holds the username, IP address and port, then associate a file for each entry in the table and write to that file (or open new file if the entry doesn't exist in the table).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    16
    I was thinking about doing a static table in memory, but I don't know the number of entries. I could have 10, or I could have 9999. Should I instead use a dynamically allocated table?

  4. #4
    Registered User
    Join Date
    Aug 2008
    Posts
    67
    Why not open/create/close text files based on user WHOIS information? Such as:

    [email protected]
    [email protected]

    I imagine a dynamic table, used in any number of active channels, would get extremely large in a short period of time, and a static table insufficient. Also keep in mind that an IP address may not always be available, depending on server settings and user modes.

  5. #5
    Registered User
    Join Date
    Apr 2006
    Posts
    16
    Quote Originally Posted by kpreston View Post
    Why not open/create/close text files based on user WHOIS information? Such as:

    [email protected]
    [email protected]

    I imagine a dynamic table, used in any number of active channels, would get extremely large in a short period of time, and a static table insufficient. Also keep in mind that an IP address may not always be available, depending on server settings and user modes.
    Hmm that takes care of two the values...and getting the third is very easy. Thanks for the idea! I was thinking of coding practices and overlooked what IRC has already done for me!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. text based mmo type game.....
    By SONAR in forum Game Programming
    Replies: 0
    Last Post: 12-09-2008, 05:17 AM
  2. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  3. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  4. ordering vector elements based on heuristic values
    By cyberfish in forum C++ Programming
    Replies: 5
    Last Post: 08-16-2007, 12:33 AM
  5. odd errors from msvc std library files
    By blight2c in forum C++ Programming
    Replies: 6
    Last Post: 04-30-2002, 12:06 AM