LoggerLevel.h 1.55 KB
Newer Older
Bryan Berthou's avatar
refs#16  
Bryan Berthou committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef LOGGER_LEVEL_H
#define LOGGER_LEVEL_H

/**
 * @file LoggerLevel.h
 * @author Bryan BERTHOU (SPhN / CEA Saclay)
 * @date 05 September 2014
 * @version 1.0
 */

#include <string>

#include "../string_utils/StringUtils.h"

namespace ElemUtils {

Nabil Chouika's avatar
Nabil Chouika committed
17
18
19
20
/**
 * @class LoggerLevel
 * @brief
 */
Bryan Berthou's avatar
refs#16  
Bryan Berthou committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
class LoggerLevel {
public:
    enum Type {
        DEBUG = 0, INFO = 1, WARN = 2, ERROR = 3, OFF = 4, NONE = 5
    };

    LoggerLevel(Type t) :
            m_type(t) {
    }

    std::string toString() const {
        switch (m_type) {
        case DEBUG:
            return "DEBUG";
            break;
        case INFO:
            return "INFO";
            break;
        case WARN:
            return "WARN";
            break;
        case ERROR:
            return "ERROR";
            break;
        case OFF:
            return "OFF";
            break;
        default:
            return "NONE";
        }
    }

    static LoggerLevel fromString(std::string level) {
        StringUtils::to_upperCase(level);
        if (level == "DEBUG") {
            return DEBUG;
        } else if (level == "INFO") {
            return INFO;
        } else if (level == "WARN") {
            return WARN;
        } else if (level == "ERROR") {
            return ERROR;
        } else if (level == "OFF") {
            return OFF;
        }

        return NONE;
    }

    LoggerLevel::Type getType() const {
        return m_type;
    }

    void setType(Type type) {
        m_type = type;
    }

private:
    LoggerLevel::Type m_type;
};

} // namespace ElemUtils

#endif /* LOGGER_LEVEL_H */