Subversion Repositories HomeAutomation

Rev

Rev 1964 | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1945 runge 1
/*
2
 *
3
 *  Copyright (C) 2012  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 LOG_H
22
#define LOG_H
23
 
24
#include <exception>
25
#include <string>
26
#include <stdio.h>
27
#include <stdint.h>
28
 
29
namespace atom {
30
namespace log {
31
 
32
typedef enum
33
{
34
  LOG_LEVEL_NONE      = 0x000000,
35
  LOG_LEVEL_ERROR     = 0x000001,
36
  LOG_LEVEL_EXCEPTION = 0x000002,
37
  LOG_LEVEL_WARNING   = 0x000004,
38
  LOG_LEVEL_INFO      = 0x000008,
39
  LOG_LEVEL_DEBUG     = 0x000010,
1990 runge 40
  LOG_LEVEL_EXTREME   = 0x000040,
1945 runge 41
  LOG_LEVEL_ALL       = 0xFFFFFF
42
} Level;
43
 
1964 runge 44
void SetLevel(Level level);
45
void SetLevelByString( std::string level_string );
1945 runge 46
 
1964 runge 47
bool OpenFile(std::string filepath);
48
void CloseFile(void);
49
 
1945 runge 50
void Info(std::string module, char* format, ...);
51
void Info(std::string module, std::string message);
52
 
53
void Debug(std::string module, char* format, ...);
54
void Debug(std::string module, std::string message);
55
 
1990 runge 56
void Extreme(std::string module, char* format, ...);
57
void Extreme(std::string module, std::string message);
58
 
1945 runge 59
void Error(std::string module, char* format, ...);
60
void Error(std::string module, std::string message);
61
 
62
void Warning(std::string module, char* format, ...);
63
void Warning(std::string module, std::string message);
64
 
65
void Exception(std::string module, std::exception& exception);
1959 runge 66
 
1990 runge 67
#define LOG_DEBUG_ENTER log::Extreme(log_module_, "%s entered!", __FUNCTION__);
68
#define LOG_DEBUG_EXIT  log::Extreme(log_module_, "%s exited!", __FUNCTION__);
1959 runge 69
 
1962 runge 70
#define LOG_DEBUG_ROW  log::Debug(log_module_, "%s at line %d!", __FUNCTION__, __LINE__);
71
 
1945 runge 72
}; // namespace log
73
}; // namespace atom
74
 
75
#endif // LOG_H
76