Subversion Repositories HomeAutomation

Rev

Go to most recent revision | Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1594 runge 1
/*
2
 *
3
 *  Copyright (C) 2010  Mattias Runge
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU General Public License as published by
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License along
16
 *  with this program; if not, write to the Free Software Foundation, Inc.,
17
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
 *
19
 */
20
 
21
#ifndef LOGGING_LOGGER_H
22
#define LOGGING_LOGGER_H
23
 
24
#include <string>
25
#include <fstream>
26
 
27
#include <boost/thread/mutex.hpp>
28
 
29
namespace atom {
30
namespace logging {
31
 
32
class Logger
33
{
34
public:
35
    typedef enum
36
    {
37
        LEVEL_NONE    = 0,
38
        LEVEL_ERROR   = 1,
39
        LEVEL_WARNING = 2,
40
        LEVEL_INFO    = 3,
41
        LEVEL_DEBUG   = 4,
42
        LEVEL_ALL     = 5
43
    } Level;
44
 
45
    Logger(std::string name);
46
    virtual ~Logger();
47
 
48
    void Error(std::string message);
49
    void Warning(std::string message);
50
    void Info(std::string message);
51
    void Debug(std::string message);
52
 
53
    static void SetLevel(Level level);
54
    static bool OpenFile(std::string filename);
55
    static void CloseFile();    
56
 
57
private:
58
    static Level level_;
59
    static std::ofstream file_;
60
    static boost::mutex mutex_;
61
 
62
    std::string name_;
63
 
64
    void Print(std::string line);
65
};    
66
 
67
}; // namespace logging
68
}; // namespace atom
69
 
70
#endif // LOGGING_LOGGER_H