src/proto2/Logger.hh
author terom
Sun, 09 Nov 2008 20:40:46 +0000
changeset 24 b81cb670e6b2
parent 23 8d802b573cf0
permissions -rw-r--r--
the great :retab
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
     1
#ifndef LOGGER_HH
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
     2
#define LOGGER_HH
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
     3
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
     4
#include <ClanLib/network.h>
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
     5
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
     6
#include <iostream>
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
     7
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
     8
enum LogLevel {
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
     9
    FATAL,
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    10
    ERROR,
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    11
    WARN,
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    12
    INFO,
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    13
    DEBUG,
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    14
};
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    15
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    16
class Logger {
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    17
    private:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    18
        std::ostream &stream;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    19
        enum LogLevel level;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    20
        const char *module;
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    21
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    22
    public:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    23
        Logger (std::ostream &stream, enum LogLevel level, const char *module);
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    24
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    25
        template <typename T> Logger& operator<< (T &val) {
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    26
            stream << val;
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    27
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    28
            return *this;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    29
        }
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    30
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    31
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    32
        ~Logger (void);
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    33
};
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    34
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    35
std::ostream& operator<< (std::ostream &s, CL_NetComputer &c);
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    36
std::ostream& operator<< (std::ostream &s, CL_NetObject_Server &obj);
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    37
std::ostream& operator<< (std::ostream &s, CL_NetObject_Client &obj);
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    38
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    39
#endif /* LOGGER_HH */