log4tango  5.0.0
Level.hh
Go to the documentation of this file.
1 //
2 // Level.hh
3 //
4 // Copyright (C) : 2000 - 2002
5 // LifeLine Networks BV (www.lifeline.nl). All rights reserved.
6 // Bastiaan Bakker. All rights reserved.
7 //
8 // 2004,2005,2006,2007,2008,2009,2010,2011,2012
9 // Synchrotron SOLEIL
10 // L'Orme des Merisiers
11 // Saint-Aubin - BP 48 - France
12 //
13 // This file is part of log4tango.
14 //
15 // Log4ango is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU Lesser General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 // Log4tango is distributed in the hope that it will be useful,
21 // but WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 // GNU Lesser General Public License for more details.
24 //
25 // You should have received a copy of the GNU Lesser General Public License
26 // along with Log4Tango. If not, see <http://www.gnu.org/licenses/>.
27 
28 #ifndef _LOG4TANGO_LEVEL_H
29 #define _LOG4TANGO_LEVEL_H
30 
31 #include <log4tango/Portability.hh>
32 #include <string>
33 #include <stdexcept>
34 
35 /*
36  * Optionally work around rudeness in windows.h on Win32.
37  */
38 #ifdef ERROR
39 #ifdef LOG4TANGO_FIX_ERROR_COLLISION
40 
41 namespace log4tango {
42  static const int _tmpERRORValue = ERROR;
43 }
44 
45 #undef ERROR
46  static const int ERROR = log4tango::_tmpERRORValue;
47 #define ERROR ERROR
48 
49 #else // LOG4TANGO_FIX_ERROR_COLLISION
50 #error Naming collision for 'ERROR' detected. Please read the FAQ for a \
51  workaround.
52 #endif // LOG4TANGO_FIX_ERROR_COLLISION
53 
54 #endif // ERROR
55 
56 /*
57  * Other Win32 rudeness in EDK.h
58  */
59 #ifdef DEBUG
60 
61 #ifdef LOG4TANGO_FIX_ERROR_COLLISION
62 
63 #undef DEBUG
64 #define DEBUG DEBUG
65 
66 #else // LOG4TANGO_FIX_ERROR_COLLISION
67 #error Naming collision for 'DEBUG' detected. Please read the FAQ for a \
68  workaround.
69 #endif // LOG4TANGO_FIX_ERROR_COLLISION
70 
71 #endif // DEBUG
72 
73 
74 namespace log4tango {
75 
76 //-----------------------------------------------------------------------------
77 // class : Level
78 //-----------------------------------------------------------------------------
80 {
81 public:
82 
86  typedef enum {
87  OFF = 100,
88  FATAL = 200,
89  ERROR = 300,
90  WARN = 400,
91  INFO = 500,
92  DEBUG = 600
93  } LevelLevel;
94 
98  typedef int Value;
99 
108  static const std::string& get_name (Value level);
109 
119  static Value get_value (const std::string& level_name)
120  throw(std::invalid_argument);
121 };
122 
123 } // namespace log4tango
124 
125 #endif // _LOG4TANGO_LEVEL_H