Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
Priority.cpp
Go to the documentation of this file.
1
/*
2
* Priority.cpp
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
#include "
PortabilityImpl.hh
"
11
#include <
log4cpp/Priority.hh
>
12
#include <cstdlib>
13
14
namespace
log4cpp
{
15
16
namespace
{
17
const
std::string *names() {
18
static
const
std::string priority_names[10] = {
19
"FATAL"
,
20
"ALERT"
,
21
"CRIT"
,
22
"ERROR"
,
23
"WARN"
,
24
"NOTICE"
,
25
"INFO"
,
26
"DEBUG"
,
27
"NOTSET"
,
28
"UNKNOWN"
29
};
30
return
priority_names;
31
}
32
}
33
34
const
int
log4cpp::Priority::MESSAGE_SIZE
= 8;
35
36
37
const
std::string&
Priority::getPriorityName
(
int
priority)
throw
() {
38
39
priority++;
40
priority /= 100;
41
return
names()[((priority < 0) || (priority > 8)) ? 8 : priority];
42
}
43
44
Priority::Value
Priority::getPriorityValue
(
const
std::string& priorityName)
45
throw
(std::invalid_argument) {
46
Priority::Value
value = -1;
47
48
for
(
unsigned
int
i = 0; i < 10; i++) {
49
if
(priorityName == names()[i]) {
50
value = i * 100;
51
break
;
52
}
53
}
54
55
if
(value == -1) {
56
if
(priorityName ==
"EMERG"
) {
57
value = 0;
58
}
else
{
59
char
* endPointer;
60
value = std::strtoul(priorityName.c_str(), &endPointer, 10);
61
if
(*endPointer != 0) {
62
throw
std::invalid_argument(
63
std::string(
"unknown priority name: '"
) + priorityName +
"'"
64
);
65
}
66
}
67
}
68
69
return
value;
70
}
71
}
PortabilityImpl.hh
log4cpp::Priority::MESSAGE_SIZE
static const int MESSAGE_SIZE
Definition:
Priority.hh:64
log4cpp
Definition:
AbortAppender.hh:16
log4cpp::Priority::Value
int Value
Definition:
Priority.hh:85
log4cpp::Priority::getPriorityName
static const std::string & getPriorityName(int priority)
Definition:
Priority.cpp:37
log4cpp::Priority::getPriorityValue
static Value getPriorityValue(const std::string &priorityName)
Definition:
Priority.cpp:44
Priority.hh
log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung
autogenerated on Sun Jun 23 2019 19:14:17