NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
ndnSIM
ndnSIM documentation
All Attributes
All GlobalValues
All LogComponents
All TraceSources
Todo List
Deprecated List
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
syslog.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2014, Peter Thorson. All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
6
* * Redistributions of source code must retain the above copyright
7
* notice, this list of conditions and the following disclaimer.
8
* * Redistributions in binary form must reproduce the above copyright
9
* notice, this list of conditions and the following disclaimer in the
10
* documentation and/or other materials provided with the distribution.
11
* * Neither the name of the WebSocket++ Project nor the
12
* names of its contributors may be used to endorse or promote products
13
* derived from this software without specific prior written permission.
14
*
15
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
19
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
*
26
*
27
* The initial version of this logging policy was contributed to the WebSocket++
28
* project by Tom Hughes.
29
*/
30
31
#ifndef WEBSOCKETPP_LOGGER_SYSLOG_HPP
32
#define WEBSOCKETPP_LOGGER_SYSLOG_HPP
33
34
#include <syslog.h>
35
36
#include <
websocketpp/logger/basic.hpp
>
37
38
#include <
websocketpp/common/cpp11.hpp
>
39
#include <
websocketpp/logger/levels.hpp
>
40
41
namespace
websocketpp
{
42
namespace
log {
43
45
template
<
typename
concurrency,
typename
names>
46
class
syslog
:
public
basic
<concurrency, names> {
47
public
:
48
typedef
basic<concurrency, names>
base
;
49
51
54
syslog<concurrency,names>
(
channel_type_hint::value
hint =
55
channel_type_hint::access
)
56
:
basic<concurrency,names>
(hint), m_channel_type_hint(hint) {}
57
59
63
syslog<concurrency,names>
(
level
channels,
channel_type_hint::value
hint =
64
channel_type_hint::access
)
65
:
basic<concurrency,names>
(channels, hint), m_channel_type_hint(hint) {}
66
68
72
void
write
(
level
channel, std::string
const
& msg) {
73
write
(channel, msg.c_str());
74
}
75
77
81
void
write
(
level
channel,
char
const
* msg) {
82
scoped_lock_type
lock(
base::m_lock
);
83
if
(!this->
dynamic_test
(channel)) {
return
; }
84
::syslog
(syslog_priority(channel),
"[%s] %s"
,
85
names::channel_name(channel), msg);
86
}
87
private
:
88
typedef
typename
base::scoped_lock_type
scoped_lock_type
;
89
92
static
int
const
default_level = LOG_INFO;
93
95
99
int
syslog_priority(
level
channel)
const
{
100
if
(m_channel_type_hint ==
channel_type_hint::access
) {
101
return
syslog_priority_access(channel);
102
}
else
{
103
return
syslog_priority_error(channel);
104
}
105
}
106
108
112
int
syslog_priority_error(
level
channel)
const
{
113
switch
(channel) {
114
case
elevel::devel
:
115
return
LOG_DEBUG;
116
case
elevel::library
:
117
return
LOG_DEBUG;
118
case
elevel::info
:
119
return
LOG_INFO;
120
case
elevel::warn
:
121
return
LOG_WARNING;
122
case
elevel::rerror
:
123
return
LOG_ERR;
124
case
elevel::fatal
:
125
return
LOG_CRIT;
126
default
:
127
return
default_level;
128
}
129
}
130
132
136
_WEBSOCKETPP_CONSTEXPR_TOKEN_
int
syslog_priority_access(
level
)
const
{
137
return
default_level;
138
}
139
140
channel_type_hint::value
m_channel_type_hint;
141
};
142
143
}
// log
144
}
// websocketpp
145
146
#endif // WEBSOCKETPP_LOGGER_SYSLOG_HPP
websocketpp::log::basic::m_lock
mutex_type m_lock
Definition:
basic.hpp:171
websocketpp::log::elevel::fatal
static level const fatal
Unrecoverable error.
Definition:
levels.hpp:78
websocketpp::log::basic::dynamic_test
bool dynamic_test(level channel)
Definition:
basic.hpp:164
websocketpp::log::channel_type_hint::value
uint32_t value
Type of a channel type hint value.
Definition:
levels.hpp:48
websocketpp::log::channel_type_hint::access
static value const access
Access log.
Definition:
levels.hpp:53
websocketpp::log::elevel::devel
static level const devel
Low level debugging information (warning: very chatty)
Definition:
levels.hpp:63
websocketpp::log::syslog::write
void write(level channel, char const *msg)
Write a cstring message to the given channel.
Definition:
syslog.hpp:81
websocketpp::log::basic::scoped_lock_type
concurrency::scoped_lock_type scoped_lock_type
Definition:
basic.hpp:169
websocketpp::log::syslog::base
basic< concurrency, names > base
Definition:
syslog.hpp:48
websocketpp::log::syslog::syslog
syslog(channel_type_hint::value hint=channel_type_hint::access)
Construct the logger.
Definition:
syslog.hpp:54
websocketpp::log::syslog
Basic logger that outputs to syslog.
Definition:
syslog.hpp:46
_WEBSOCKETPP_CONSTEXPR_TOKEN_
#define _WEBSOCKETPP_CONSTEXPR_TOKEN_
Definition:
cpp11.hpp:132
websocketpp::log::basic
Basic logger that outputs to an ostream.
Definition:
basic.hpp:59
websocketpp::log::syslog::write
void write(level channel, std::string const &msg)
Write a string message to the given channel.
Definition:
syslog.hpp:72
websocketpp::log::elevel::info
static level const info
Information about minor configuration problems or additional information about other warnings...
Definition:
levels.hpp:69
websocketpp
Namespace for the WebSocket++ project.
Definition:
base64.hpp:41
levels.hpp
cpp11.hpp
basic.hpp
websocketpp::log::level
uint32_t level
Type of a channel package.
Definition:
levels.hpp:37
websocketpp::log::elevel::library
static level const library
Information about unusual system states or other minor internal library problems, less chatty than de...
Definition:
levels.hpp:66
websocketpp::log::elevel::rerror
static level const rerror
Recoverable error.
Definition:
levels.hpp:75
websocketpp::log::elevel::warn
static level const warn
Information about important problems not severe enough to terminate connections.
Definition:
levels.hpp:72
ndnSIM
NFD
websocketpp
websocketpp
logger
syslog.hpp
Generated on Thu Nov 2 2017 03:30:30 for ndnSIM by
1.8.11