ns-3 Direct Code Execution
Home
Tutorials ▼
Docs ▼
Wiki
Manual
Develop ▼
API
Bugs
API
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
dce-syslog.cc
Go to the documentation of this file.
1
2
#include "
dce-syslog.h
"
3
#include "
dce-stdio.h
"
4
#include <ns3/log.h>
5
#include <ns3/node.h>
6
#include <ns3/simulator.h>
7
8
#include "
dce-manager.h
"
9
#include "
process.h
"
10
#include "
utils.h
"
11
12
#include <sstream>
13
14
NS_LOG_COMPONENT_DEFINE
(
"DceSyslog"
);
15
16
using namespace
ns3;
17
18
void
19
dce_openlog
(
const
char
*ident,
int
logopt,
int
facility)
20
{
21
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
() << ident << logopt << facility);
22
NS_ASSERT (
Current
() != 0);
23
Process
*process =
Current
()->
process
;
24
25
std::ostringstream os;
// form the syslog filename
26
os <<
"/var/log/"
<< process->
pid
<<
"/syslog"
;
27
process->
syslog
=
dce_fopen
(os.str ().c_str (),
"w"
);
28
NS_ASSERT_MSG (process->
syslog
!= 0,
"Cannot open "
<< os.str () <<
" file to output all syslog messages"
);
29
}
30
31
void
32
dce_closelog
(
void
)
33
{
34
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
());
35
NS_ASSERT (
Current
() != 0);
36
Process
*process =
Current
()->
process
;
37
38
dce_fclose
(process->
syslog
);
39
}
40
41
int
42
dce_setlogmask
(
int
maskpri)
43
{
44
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
() << maskpri);
45
NS_ASSERT (
Current
() != 0);
46
// ignore
47
}
48
49
void
50
dce_syslog
(
int
priority,
const
char
*message, ...)
51
{
52
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
() << priority << message);
53
NS_ASSERT (
Current
() != 0);
54
55
va_list ap;
56
va_start (ap, message);
57
dce_vsyslog
(priority, message, ap);
58
va_end (ap);
59
}
60
61
void
62
dce_vsyslog
(
int
priority,
const
char
*message, va_list args)
63
{
64
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
() << priority << message);
65
NS_ASSERT (
Current
() != 0);
66
Process
*process =
Current
()->
process
;
67
68
vfprintf (process->
syslog
, message, args);
69
fprintf (process->
syslog
,
"\n"
);
70
}
model
dce-syslog.cc
Generated on Fri Aug 30 2013 13:57:55 for ns-3-dce by
1.8.1.2