Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
FSL
utils
Commits
04dc46b6
Commit
04dc46b6
authored
20 years ago
by
Mark Woolrich
Browse files
Options
Downloads
Patches
Plain Diff
*** empty log message ***
parent
22a3e0d7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
log.cc
+41
-0
41 additions, 0 deletions
log.cc
log.h
+5
-0
5 additions, 0 deletions
log.h
with
46 additions
and
0 deletions
log.cc
+
41
−
0
View file @
04dc46b6
...
...
@@ -82,6 +82,47 @@ namespace Utilities {
logEstablished
=
true
;
}
void
Log
::
setthenmakeDir
(
const
string
&
pdirname
,
const
string
&
plogfilename
,
bool
pstream_to_logfile
,
bool
pstream_to_cout
)
{
if
(
logEstablished
)
{
logfileout
.
close
();
}
dir
=
pdirname
;
logfilename
=
plogfilename
;
stream_to_logfile
=
pstream_to_logfile
;
stream_to_cout
=
pstream_to_cout
;
ifstream
dirif
;
dirif
.
open
(
dir
.
c_str
(),
ios
::
in
);
bool
direxists
=
!
logfileout
.
bad
();
cout
<<
"direxists = "
<<
direxists
<<
endl
;
if
(
!
direxists
)
{
// make directory
int
ret
=
system
((
"mkdir "
+
dir
+
" 2>/dev/null"
).
c_str
());
if
(
ret
==
0
)
{
throw
Exception
(
string
(
string
(
"Unable to make directory "
)
+
dir
).
c_str
());
}
}
// setup logfile
if
(
stream_to_logfile
)
{
logfileout
.
open
((
dir
+
"/"
+
logfilename
).
c_str
(),
ios
::
out
);
if
(
logfileout
.
bad
())
{
throw
Exception
(
string
(
string
(
"Unable to setup logfile "
)
+
logfilename
+
string
(
" in directory "
)
+
dir
).
c_str
());
}
}
logEstablished
=
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
log.h
+
5
−
0
View file @
04dc46b6
...
...
@@ -90,6 +90,11 @@ namespace Utilities{
/** The stream_to* variables define the streaming behaviour */
void
setDir
(
const
string
&
pdirname
,
const
string
&
plogfilename
=
"logfile"
,
bool
pstream_to_logfile
=
true
,
bool
pstream_to_cout
=
false
);
/** Sets an existing directory to place results into. */
/** If does not exist then makes it. */
/** The stream_to* variables define the streaming behaviour */
void
setthenmakeDir
(
const
string
&
pdirname
,
const
string
&
plogfilename
=
"logfile"
,
bool
pstream_to_logfile
=
true
,
bool
pstream_to_cout
=
false
);
/** Closes old logfile buffer and attempts to open new one with name specified and sets streaming to logfile on */
void
setLogFile
(
const
string
&
plogfilename
);
...
...
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