src/Logger.cc
author Tero Marttila <terom@fixme.fi>
Thu, 22 Jan 2009 02:38:33 +0200
branchnew_graphics
changeset 418 194bc810a570
parent 412 721c60072091
permissions -rw-r--r--
add --log-level option, improve Config/Logger documentation, fix NETWORK_EANBLED typos in Engine
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     1
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     2
#include "Logger.hh"
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     3
418
194bc810a570 add --log-level option, improve Config/Logger documentation, fix NETWORK_EANBLED typos in Engine
Tero Marttila <terom@fixme.fi>
parents: 412
diff changeset
     4
Logger::Logger (std::ostream &stream, LogLevel level, const char *module, LogLevel max_level) : 
194bc810a570 add --log-level option, improve Config/Logger documentation, fix NETWORK_EANBLED typos in Engine
Tero Marttila <terom@fixme.fi>
parents: 412
diff changeset
     5
    stream(stream), show(level <= max_level)
365
65295dfbbf64 fix optimization-related warnings
terom
parents: 185
diff changeset
     6
{
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     7
    const char *l;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     8
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     9
    switch (level) {
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    10
        case FATAL: l = "FATAL"; break;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    11
        case ERROR: l = "ERROR"; break;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    12
        case WARN: l = "WARN"; break;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    13
        case INFO: l = "INFO"; break;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    14
        case DEBUG: l = "DEBUG"; break;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    15
        default: l = "???"; break;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    16
    };
418
194bc810a570 add --log-level option, improve Config/Logger documentation, fix NETWORK_EANBLED typos in Engine
Tero Marttila <terom@fixme.fi>
parents: 412
diff changeset
    17
    
194bc810a570 add --log-level option, improve Config/Logger documentation, fix NETWORK_EANBLED typos in Engine
Tero Marttila <terom@fixme.fi>
parents: 412
diff changeset
    18
    if (show)
194bc810a570 add --log-level option, improve Config/Logger documentation, fix NETWORK_EANBLED typos in Engine
Tero Marttila <terom@fixme.fi>
parents: 412
diff changeset
    19
        stream << l << " [" << module << "] ";
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    20
}
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    21
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    22
Logger::~Logger (void) {
418
194bc810a570 add --log-level option, improve Config/Logger documentation, fix NETWORK_EANBLED typos in Engine
Tero Marttila <terom@fixme.fi>
parents: 412
diff changeset
    23
    if (show)
194bc810a570 add --log-level option, improve Config/Logger documentation, fix NETWORK_EANBLED typos in Engine
Tero Marttila <terom@fixme.fi>
parents: 412
diff changeset
    24
        stream << std::endl;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    25
}
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    26