Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
JPSreport
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
JuPedSim
JPSreport
Commits
fe66fa49
Commit
fe66fa49
authored
May 15, 2018
by
Mohcine Chraibi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option for logile
<logfile>log.txt</logfile>
parent
e26550b4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
61 deletions
+88
-61
Analysis.cpp
Analysis.cpp
+0
-21
general/ArgumentParser.cpp
general/ArgumentParser.cpp
+86
-3
general/ArgumentParser.h
general/ArgumentParser.h
+2
-1
main.cpp
main.cpp
+0
-36
No files found.
Analysis.cpp
View file @
fe66fa49
...
...
@@ -119,27 +119,6 @@ void Analysis::InitArgs(ArgumentParser* args)
{
string
s
=
"Parameter:
\n
"
;
switch
(
args
->
GetLog
())
{
case
0
:
// no log file
//Log = new OutputHandler();
break
;
case
1
:
if
(
Log
)
delete
Log
;
Log
=
new
STDIOHandler
();
break
;
case
2
:
{
char
name
[
CLENGTH
]
=
""
;
sprintf
(
name
,
"%s.P0.dat"
,
args
->
GetErrorLogFile
().
c_str
());
if
(
Log
)
delete
Log
;
Log
=
new
FileHandler
(
name
);
}
break
;
default:
Log
->
Write
(
"Wrong option for Log file!"
);
exit
(
0
);
}
if
(
args
->
GetIsMethodA
())
{
_DoesUseMethodA
=
true
;
vector
<
int
>
Measurement_Area_IDs
=
args
->
GetAreaIDforMethodA
();
...
...
general/ArgumentParser.cpp
View file @
fe66fa49
...
...
@@ -53,6 +53,34 @@
using
namespace
std
;
/* https://stackoverflow.com/questions/38530981/output-compiler-version-in-a-c-program#38531037 */
std
::
string
ver_string
(
int
a
,
int
b
,
int
c
)
{
std
::
ostringstream
ss
;
ss
<<
a
<<
'.'
<<
b
<<
'.'
<<
c
;
return
ss
.
str
();
}
std
::
string
true_cxx
=
#ifdef __clang__
"clang++"
;
#else
"g++"
;
#endif
std
::
string
true_cxx_ver
=
#ifdef __clang__
ver_string
(
__clang_major__
,
__clang_minor__
,
__clang_patchlevel__
);
#else
ver_string
(
__GNUC__
,
__GNUC_MINOR__
,
__GNUC_PATCHLEVEL__
);
#endif
// todo: handle Visual Studio
/* #ifdef _MSC_VER */
/* std::to_string(_MSC_VER) */
/* #endif */
void
ArgumentParser
::
Usage
(
const
std
::
string
file
)
{
...
...
@@ -83,8 +111,8 @@ ArgumentParser::ArgumentParser()
_steadyEnd
=
1000
;
_grid_size_X
=
10
;
_grid_size_Y
=
10
;
_errorLogFile
=
"
./Logfile.da
t"
;
_log
=
1
;
//no output wanted
_errorLogFile
=
"
log.tx
t"
;
_log
=
2
;
//no output wanted
_trajectoriesLocation
=
"./"
;
_trajectoriesFilename
=
""
;
_projectRootDir
=
"./"
;
...
...
@@ -150,7 +178,14 @@ const string& ArgumentParser::GetProjectRootDir() const
bool
ArgumentParser
::
ParseIniFile
(
const
string
&
inifile
)
{
// first logs will go to stdout
Log
->
Write
(
"----
\n
JuPedSim - JPSreport
\n
"
);
Log
->
Write
(
"Current date : %s %s"
,
__DATE__
,
__TIME__
);
Log
->
Write
(
"Version : %s"
,
JPSREPORT_VERSION
);
Log
->
Write
(
"Compiler : %s (%s)"
,
true_cxx
.
c_str
(),
true_cxx_ver
.
c_str
());
Log
->
Write
(
"Commit hash : %s"
,
GIT_COMMIT_HASH
);
Log
->
Write
(
"Commit date : %s"
,
GIT_COMMIT_DATE
);
Log
->
Write
(
"Branch : %s
\n
----
\n
"
,
GIT_BRANCH
);
Log
->
Write
(
"INFO:
\t
Parsing the ini file <%s>"
,
inifile
.
c_str
());
//extract and set the project root dir
...
...
@@ -179,6 +214,45 @@ bool ArgumentParser::ParseIniFile(const string& inifile)
return
false
;
}
if
(
xMainNode
->
FirstChild
(
"logfile"
))
{
this
->
SetErrorLogFile
(
this
->
GetProjectRootDir
()
+
xMainNode
->
FirstChild
(
"logfile"
)
->
FirstChild
()
->
Value
());
this
->
SetLog
(
2
);
Log
->
Write
(
"INFO:
\t
logfile <%s>"
,
this
->
GetErrorLogFile
().
c_str
());
}
switch
(
this
->
GetLog
())
{
case
0
:
// no log file
//Log = new OutputHandler();
break
;
case
1
:
if
(
Log
)
delete
Log
;
Log
=
new
STDIOHandler
();
break
;
case
2
:
{
char
name
[
CLENGTH
]
=
""
;
sprintf
(
name
,
"%s"
,
this
->
GetErrorLogFile
().
c_str
());
if
(
Log
)
delete
Log
;
Log
=
new
FileHandler
(
name
);
}
break
;
default:
Log
->
Write
(
"ERROR:
\t
Wrong option for Log file!"
);
exit
(
0
);
}
// from this point if case 2, the logs will go to a logfile
if
(
this
->
GetLog
()
==
2
)
{
Log
->
Write
(
"----
\n
JuPedSim - JPSreport
\n
"
);
Log
->
Write
(
"Current date : %s %s"
,
__DATE__
,
__TIME__
);
Log
->
Write
(
"Version : %s"
,
JPSREPORT_VERSION
);
Log
->
Write
(
"Compiler : %s (%s)"
,
true_cxx
.
c_str
(),
true_cxx_ver
.
c_str
());
Log
->
Write
(
"Commit hash : %s"
,
GIT_COMMIT_HASH
);
Log
->
Write
(
"Commit date : %s"
,
GIT_COMMIT_DATE
);
Log
->
Write
(
"Branch : %s
\n
----
\n
"
,
GIT_BRANCH
);
}
//geometry
if
(
xMainNode
->
FirstChild
(
"geometry"
))
{
...
...
@@ -975,3 +1049,12 @@ MeasurementArea* ArgumentParser::GetMeasurementArea(int id)
return
_measurementAreas
[
id
];
}
void
ArgumentParser
::
SetErrorLogFile
(
std
::
string
errorLogFile
)
{
_errorLogFile
=
errorLogFile
;
};
void
ArgumentParser
::
SetLog
(
int
log
)
{
_log
=
log
;
};
general/ArgumentParser.h
View file @
fe66fa49
...
...
@@ -151,7 +151,8 @@ public:
float
GetGridSizeY
()
const
;
int
GetLog
()
const
;
bool
ParseArgs
(
int
argc
,
char
**
argv
);
void
SetErrorLogFile
(
std
::
string
errorLogFile
);
void
SetLog
(
int
log
);
MeasurementArea
*
GetMeasurementArea
(
int
id
);
/**
...
...
main.cpp
View file @
fe66fa49
...
...
@@ -34,44 +34,10 @@
#include "Analysis.h"
using
namespace
std
;
/* https://stackoverflow.com/questions/38530981/output-compiler-version-in-a-c-program#38531037 */
std
::
string
ver_string
(
int
a
,
int
b
,
int
c
)
{
std
::
ostringstream
ss
;
ss
<<
a
<<
'.'
<<
b
<<
'.'
<<
c
;
return
ss
.
str
();
}
std
::
string
true_cxx
=
#ifdef __clang__
"clang++"
;
#else
"g++"
;
#endif
std
::
string
true_cxx_ver
=
#ifdef __clang__
ver_string
(
__clang_major__
,
__clang_minor__
,
__clang_patchlevel__
);
#else
ver_string
(
__GNUC__
,
__GNUC_MINOR__
,
__GNUC_PATCHLEVEL__
);
#endif
// todo: handle Visual Studio
/* #ifdef _MSC_VER */
/* std::to_string(_MSC_VER) */
/* #endif */
int
main
(
int
argc
,
char
**
argv
)
{
Log
=
new
STDIOHandler
();
Log
->
Write
(
"----
\n
JuPedSim - JPSreport
\n
"
);
Log
->
Write
(
"Current date : %s %s"
,
__DATE__
,
__TIME__
);
Log
->
Write
(
"Version : %s"
,
JPSREPORT_VERSION
);
Log
->
Write
(
"Compiler : %s (%s)"
,
true_cxx
.
c_str
(),
true_cxx_ver
.
c_str
());
Log
->
Write
(
"Commit hash : %s"
,
GIT_COMMIT_HASH
);
Log
->
Write
(
"Commit date : %s"
,
GIT_COMMIT_DATE
);
// Log->Write("Commit subject : %s", GIT_COMMIT_SUBJECT);
Log
->
Write
(
"Branch : %s
\n
----
\n
"
,
GIT_BRANCH
);
// Parsing the arguments
ArgumentParser
*
args
=
new
ArgumentParser
();
...
...
@@ -81,8 +47,6 @@ int main(int argc, char **argv)
// get the number of file to analyse
const
vector
<
string
>&
files
=
args
->
GetTrajectoriesFiles
();
const
string
&
path
=
args
->
GetTrajectoriesLocation
();
//path="";
// create and initialize the analysis engine
for
(
unsigned
int
i
=
0
;
i
<
files
.
size
();
i
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment