Skip to main content
GameDev.net gamedev.net
🔒 Locked

Logging

Started by Veslefrikk Jan 16, 2008 at 4:10 AM 3 replies 900+ views
Original Post
Veslefrikk
Veslefrikk
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
Evil Steve
Evil Steve
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.
Adam_42
Adam_42
I'd just use OutputDebugString() and DebugView
Veslefrikk
Veslefrikk
Sounds like exactly what I need.

:)

Stefan
Mawww
Mawww
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.
Tchou kanaky ! tchou !

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.