Logging

Started by
3 comments, last by Mawww 16 years, 3 months ago
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
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.
I'd just use OutputDebugString() and DebugView
Sounds like exactly what I need.

:)

Stefan
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 !

This topic is closed to new replies.

Advertisement