~ubuntu-branches/ubuntu/trusty/log4shib/trusty

« back to all changes in this revision

Viewing changes to include/log4shib/Priority.hh

  • Committer: Package Import Robot
  • Author(s): Russ Allbery
  • Date: 2012-06-05 21:20:25 UTC
  • Revision ID: package-import@ubuntu.com-20120605212025-uyigtav7dqwvnf41
Tags: upstream-1.0.4
ImportĀ upstreamĀ versionĀ 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Priority.hh
 
3
 *
 
4
 * Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
 
5
 * Copyright 2000, Bastiaan Bakker. All rights reserved.
 
6
 *
 
7
 * See the COPYING file for the terms of usage and distribution.
 
8
 */
 
9
 
 
10
#ifndef _LOG4SHIB_PRIORITY_HH
 
11
#define _LOG4SHIB_PRIORITY_HH
 
12
 
 
13
#include <log4shib/Portability.hh>
 
14
#include <string>
 
15
#include <stdexcept>
 
16
 
 
17
/*
 
18
 * Optionally work around rudeness in windows.h on Win32.
 
19
 */
 
20
#ifdef ERROR
 
21
#ifdef LOG4SHIB_FIX_ERROR_COLLISION
 
22
 
 
23
namespace log4shib {
 
24
    static const int _tmpERRORValue = ERROR;
 
25
}
 
26
 
 
27
#undef ERROR
 
28
    static const int ERROR = log4shib::_tmpERRORValue;
 
29
#define ERROR ERROR
 
30
 
 
31
#else  // LOG4SHIB_FIX_ERROR_COLLISION
 
32
#error Naming collision for 'ERROR' detected. Please read the FAQ for a \
 
33
       workaround. 
 
34
#endif // LOG4SHIB_FIX_ERROR_COLLISION 
 
35
 
 
36
#endif // ERROR
 
37
 
 
38
/*
 
39
 * Other Win32 rudeness in EDK.h
 
40
 */
 
41
#ifdef DEBUG
 
42
 
 
43
#ifdef LOG4SHIB_FIX_ERROR_COLLISION
 
44
 
 
45
#undef DEBUG
 
46
#define DEBUG DEBUG
 
47
 
 
48
#else  // LOG4SHIB_FIX_ERROR_COLLISION
 
49
#error Naming collision for 'DEBUG' detected. Please read the FAQ for a \
 
50
       workaround. 
 
51
#endif // LOG4SHIB_FIX_ERROR_COLLISION 
 
52
 
 
53
#endif // DEBUG
 
54
 
 
55
 
 
56
namespace log4shib {
 
57
 
 
58
    /**
 
59
     * The Priority class provides importance levels with which one
 
60
     * can categorize log messages.
 
61
     **/
 
62
    class LOG4SHIB_EXPORT Priority {
 
63
        public:
 
64
 
 
65
        /**
 
66
         * Predefined Levels of Priorities. These correspond to the
 
67
         * priority levels used by syslog(3).
 
68
         **/
 
69
        typedef enum {EMERG  = 0, 
 
70
                      FATAL  = 0,
 
71
                      ALERT  = 100,
 
72
                      CRIT   = 200,
 
73
                      ERROR  = 300, 
 
74
                      WARN   = 400,
 
75
                      NOTICE = 500,
 
76
                      INFO   = 600,
 
77
                      DEBUG  = 700,
 
78
                      NOTSET = 800
 
79
        } PriorityLevel;
 
80
 
 
81
        /**
 
82
         * The type of Priority Values
 
83
         **/
 
84
        typedef int Value;
 
85
 
 
86
        /**
 
87
         * Returns the name of the given priority value.
 
88
         * Currently, if the value is not one of the PriorityLevel values,
 
89
         * the method returns the name of the largest priority smaller 
 
90
         * the given value.
 
91
         * @param priority the numeric value of the priority.
 
92
         * @returns a string representing the name of the priority.
 
93
         **/
 
94
        static const std::string& getPriorityName(int priority) throw();
 
95
        
 
96
        /**
 
97
         * Returns the value of the given priority name. 
 
98
         * This can be either one of EMERG ... NOTSET or a 
 
99
         * decimal string representation of the value, e.g. '700' for DEBUG.
 
100
         * @param priorityName the string containing the the of the priority
 
101
         * @return the value corresponding with the priority name
 
102
         * @throw std::invalid_argument if the priorityName does not 
 
103
         * correspond with a known Priority name or a number
 
104
         **/
 
105
        static Value getPriorityValue(const std::string& priorityName)
 
106
        throw(std::invalid_argument);
 
107
    };
 
108
}
 
109
 
 
110
#endif // _LOG4SHIB_PRIORITY_HH