src/Logger.hh
author terom
Tue, 09 Dec 2008 04:33:53 +0000
changeset 365 65295dfbbf64
parent 283 7540b0859579
child 418 194bc810a570
permissions -rw-r--r--
fix optimization-related warnings
#ifndef LOGGER_HH
#define LOGGER_HH

#include <ClanLib/network.h>

#include <iostream>

/**
 * Message severity, WARN and above should go to stderr, INFO and DEBUG to stdout
 *
 * @see Engine::log
 */
enum LogLevel {
    FATAL,
    ERROR,
    WARN,
    INFO,
    DEBUG,
};

/**
 * Utility class used for logging, use Engine::log to construct these
 *
 * @see Engine::log
 */
class Logger {
    private:
        std::ostream &stream;
        enum LogLevel level;
        const char *module;

    public:
        Logger (std::ostream &stream, enum LogLevel level, const char *module);

        template <typename T> Logger& operator<< (const T val) {
#ifndef NDEBUG
            stream << val;
#else
            (void) val;            
#endif

            return *this;
        }

        ~Logger (void);
};

std::ostream& operator<< (std::ostream &s, CL_NetComputer &c);
std::ostream& operator<< (std::ostream &s, CL_NetObject_Server &obj);
std::ostream& operator<< (std::ostream &s, CL_NetObject_Client &obj);

#endif /* LOGGER_HH */