Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ag-ohlberger
dune-community
dune-xt
Commits
acc57b7b
Commit
acc57b7b
authored
12 years ago
by
René Fritze
Browse files
Options
Downloads
Patches
Plain Diff
[logger] fixes file creation issue
parent
5e3ae911
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/stuff/common/logging.hh
+20
-27
20 additions, 27 deletions
dune/stuff/common/logging.hh
with
20 additions
and
27 deletions
dune/stuff/common/logging.hh
+
20
−
27
View file @
acc57b7b
...
...
@@ -23,6 +23,8 @@
#include
<boost/range/adaptors.hpp>
#include
<boost/foreach.hpp>
#include
<boost/filesystem.hpp>
#include
<boost/filesystem/path.hpp>
namespace
Dune
{
namespace
Stuff
{
...
...
@@ -77,27 +79,19 @@ public:
* \param logflags any OR'd combination of flags
* \param logfile filename for log, can contain paths, but creation will fail if dir is non-existant
**/
void
create
(
int
logflags
=
(
LOG_FILE
|
LOG_CONSOLE
|
LOG_ERROR
),
std
::
string
logfile
=
"dune_stuff_log"
,
std
::
string
datadir
=
"data"
,
std
::
string
logdir
=
std
::
string
(
""
))
void
create
(
int
logflags
=
(
LOG_FILE
|
LOG_CONSOLE
|
LOG_ERROR
),
const
std
::
string
logfile
=
"dune_stuff_log"
,
const
std
::
string
datadir
=
"data"
,
const
std
::
string
_
logdir
=
std
::
string
(
"
logs
"
))
{
logflags_
=
logflags
;
// if we get a logdir from parameters append path seperator, otherwise leave empty
// enables us to use logdir unconditionally further down
if
(
!
datadir
.
empty
())
datadir
+=
"/"
;
if
(
!
logdir
.
empty
())
logdir
+=
"/"
;
logdir
=
datadir
+
logdir
;
filename_
=
logdir
+
logfile
+
"_time.log"
;
Stuff
::
Common
::
Filesystem
::
testCreateDirectory
(
logdir
);
filenameWoTime_
=
logdir
+
logfile
+
".log"
;
using
namespace
boost
::
filesystem
;
logflags_
=
logflags
;
path
logdir
=
path
(
datadir
)
/
_logdir
;
filename_
=
logdir
/
(
logfile
+
"_time.log"
);
Stuff
::
Common
::
Filesystem
::
testCreateDirectory
(
filename_
.
string
());
filenameWoTime_
=
logdir
/
(
logfile
+
".log"
);
if
((
logflags_
&
LOG_FILE
)
!=
0
)
{
logfile_
.
open
(
filename_
.
c_str
()
);
logfile_
.
open
(
filename_
);
assert
(
logfile_
.
is_open
());
logfileWoTime_
.
open
(
filenameWoTime_
.
c_str
()
);
logfileWoTime_
.
open
(
filenameWoTime_
);
assert
(
logfileWoTime_
.
is_open
());
}
IdVecCIter
it
=
streamIDs_
.
begin
();
...
...
@@ -106,10 +100,9 @@ public:
streammap_
[
*
it
]
=
new
FileLogStream
(
*
it
,
flagmap_
[
*
it
],
logfile_
,
logfileWoTime_
);
}
// create the MatlabLogStream
std
::
string
matlabLogFileName
=
logdir
+
logfile
+
"_matlab.m"
;
Stuff
::
Common
::
Filesystem
::
testCreateDirectory
(
matlabLogFileName
);
// could assert this if i figure out
// why errno is != EEXIST
matlabLogFile_
.
open
(
matlabLogFileName
.
c_str
());
path
matlabLogFileName
=
logdir
/
(
logfile
+
"_matlab.m"
);
Stuff
::
Common
::
Filesystem
::
testCreateDirectory
(
matlabLogFileName
.
string
());
matlabLogFile_
.
open
(
matlabLogFileName
);
assert
(
matlabLogFile_
.
is_open
());
matlabLogStreamPtr
=
new
MatlabLogStream
(
LOG_FILE
,
logflags_
,
matlabLogFile_
);
}
// Create
...
...
@@ -287,11 +280,11 @@ public:
};
private
:
st
d
::
string
filename_
;
st
d
::
string
filenameWoTime_
;
std
::
ofstream
logfile_
;
std
::
ofstream
logfileWoTime_
;
std
::
ofstream
matlabLogFile_
;
boo
st
::
filesystem
::
path
filename_
;
boo
st
::
filesystem
::
path
filenameWoTime_
;
boost
::
filesystem
::
ofstream
logfile_
;
boost
::
filesystem
::
ofstream
logfileWoTime_
;
boost
::
filesystem
::
ofstream
matlabLogFile_
;
typedef
std
::
map
<
int
,
int
>
FlagMap
;
FlagMap
flagmap_
;
typedef
std
::
map
<
int
,
LogStream
*>
StreamMap
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment