Branch data Line data Source code
1 : : // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
2 : : //
3 : : // Permission to use, copy, modify, and/or distribute this software for any
4 : : // purpose with or without fee is hereby granted, provided that the above
5 : : // copyright notice and this permission notice appear in all copies.
6 : : //
7 : : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
8 : : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9 : : // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
10 : : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11 : : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
12 : : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13 : : // PERFORMANCE OF THIS SOFTWARE.
14 : :
15 : : #ifndef __LOGGER_LEVEL_H
16 : : #define __LOGGER_LEVEL_H
17 : :
18 : : #include <string>
19 : :
20 : : namespace isc {
21 : : namespace log {
22 : :
23 : : /// \brief Severity Levels
24 : : ///
25 : : /// Defines the severity levels for logging. This is shared between the logger
26 : : /// and the implementations classes.
27 : : ///
28 : : /// N.B. The order of the levels - DEBUG less than INFO less that WARN etc. is
29 : : /// implicitly assumed in several implementations. They must not be changed.
30 : :
31 : : typedef enum {
32 : : DEFAULT = 0, // Default to logging level of the parent
33 : : DEBUG = 1,
34 : : INFO = 2,
35 : : WARN = 3,
36 : : ERROR = 4,
37 : : FATAL = 5,
38 : : NONE = 6 // Disable logging
39 : : } Severity;
40 : :
41 : : /// Minimum/maximum debug levels.
42 : :
43 : : const int MIN_DEBUG_LEVEL = 0;
44 : : const int MAX_DEBUG_LEVEL = 99;
45 : :
46 : : /// \brief Log level structure
47 : : ///
48 : : /// A simple pair structure that provides suitable names for the members. It
49 : : /// holds a combination of logging severity and debug level.
50 : : struct Level {
51 : : Severity severity; ///< Logging severity
52 : : int dbglevel; ///< Debug level
53 : :
54 : : Level(Severity sev = DEFAULT, int dbg = MIN_DEBUG_LEVEL) :
55 : 79536 : severity(sev), dbglevel(dbg)
56 : : {}
57 : :
58 : : // Default assignment and copy constructor is appropriate
59 : : };
60 : :
61 : : /// \brief Returns the isc::log::Severity value represented by the given string
62 : : ///
63 : : /// This must be one of the strings "DEBUG", "INFO", "WARN", "ERROR", "FATAL" or
64 : : /// "NONE". (Case is not important, but the string most not contain leading or
65 : : /// trailing spaces.)
66 : : ///
67 : : /// \param sev_str The string representing severity value
68 : : ///
69 : : /// \return The severity. If the string is not recognized, an error will be
70 : : /// logged and the string will return isc::log::INFO.
71 : : isc::log::Severity getSeverity(const std::string& sev_str);
72 : :
73 : : } // namespace log
74 : : } // namespace isc
75 : :
76 : : #endif // __LOGGER_LEVEL_H
|