Jump to content
  • Advertisement
Sign in to follow this  
Veslefrikk

Logging

This topic is 3810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, until now ive been doing logging to disk from my applications. But as Ive got a laptop as well, so I though it would be a good idea to be able to send my msg through our lan and have them displayed there, on a console window. I was wondering if anyone here have a similar setup or can give me some hints on how to implement this.. Any help is very appreciated.. Stefan

Share this post


Link to post
Share on other sites
Advertisement
Sounds a bit overkill to me, but a nice feature [smile]

You'll want to have an application running as a server, which just accepts a connection, then displays whatever comes in on that connection in a console window.
You'll also want some code in your app to connect to the log server and send log messages to it.

See the Multiplayer And Network Programming Forum FAQ for various network libraries and tutorials, although I'd just use plain Windows sockets for something this simple (Assuming you're running on Windows). I have some basic Winsock client/server code I can post if you want.

Share this post


Link to post
Share on other sites
On the design side, you may use a logger interface, and a different implementation, and a composite logger (not sure about the pattern name)

[source lang=c++]
class logger {
public:
virtual void log(const std::string& message) = 0
};

class disk_logger : public logger {
...
}

class net_logger : public logger {
...
}

class composite_logger : public logger {
private:
std::vector<logger*> m_loggers;
public:
void add(logger* logger) {
m_loggers.push_back(logger);
}
void log(const std::string& message) {
for each log in m_loggers
log->log(message);
}
};



that way implementing a new logging method is a breeze. just use a composite logger with the others attached to it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!