Subversion Repositories HomeAutomation

Rev

Rev 1962 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  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,
  40.   LOG_LEVEL_ALL       = 0xFFFFFF
  41. } Level;
  42.  
  43. void SetLevel(Level level);
  44. void SetLevelByString( std::string level_string );
  45.  
  46. bool OpenFile(std::string filepath);
  47. void CloseFile(void);
  48.  
  49. void Info(std::string module, char* format, ...);
  50. void Info(std::string module, std::string message);
  51.  
  52. void Debug(std::string module, char* format, ...);
  53. void Debug(std::string module, std::string message);
  54.  
  55. void Error(std::string module, char* format, ...);
  56. void Error(std::string module, std::string message);
  57.  
  58. void Warning(std::string module, char* format, ...);
  59. void Warning(std::string module, std::string message);
  60.  
  61. void Exception(std::string module, std::exception& exception);
  62.  
  63. #define LOG_DEBUG_ENTER log::Debug(log_module_, "%s entered!", __FUNCTION__);
  64. #define LOG_DEBUG_EXIT  log::Debug(log_module_, "%s exited!", __FUNCTION__);
  65.  
  66. #define LOG_DEBUG_ROW  log::Debug(log_module_, "%s at line %d!", __FUNCTION__, __LINE__);
  67.  
  68. }; // namespace log
  69. }; // namespace atom
  70.  
  71. #endif // LOG_H
  72.  
  73.