src/proto2/Logger.cc
author terom
Thu, 20 Nov 2008 23:45:33 +0000
branchno-netsession
changeset 41 ca80cd67785d
parent 24 b81cb670e6b2
permissions -rw-r--r--
merge r64 through r88 from trunk
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
     1
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
     2
#include "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
Logger::Logger (std::ostream &stream, enum LogLevel level, const char *module) : stream(stream), level(level), module(module) {
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
     5
    const char *l;
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
     6
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
     7
    switch (level) {
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
     8
        case FATAL: l = "FATAL"; break;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
     9
        case ERROR: l = "ERROR"; break;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    10
        case WARN: l = "WARN"; break;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    11
        case INFO: l = "INFO"; break;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    12
        case DEBUG: l = "DEBUG"; break;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    13
        default: l = "???"; break;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    14
    };
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    15
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    16
    stream << l << " [" << module << "] ";
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    17
}
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    18
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    19
Logger::~Logger (void) {
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    20
    stream << std::endl;
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    21
}
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    22
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    23
std::ostream& operator<< (std::ostream &s, CL_NetComputer &c) {
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    24
    s << "[" << c.get_address().get_address() << ":" << c.get_address().get_port() << "]";
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    25
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    26
    return s;
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    27
}
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    28
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    29
std::ostream& operator<< (std::ostream &s, CL_NetObject_Server &obj) {
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    30
    s << "%" << obj.get_obj_id();
23
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
    return s;
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_NetObject_Client &obj) {
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    36
    s << "%" << obj.get_obj_id();
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    37
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    38
    return s;
23
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    39
}
8d802b573cf0 fixed more network code, there's actually a high probability of it working now
terom
parents:
diff changeset
    40