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
b2b23ffb
Commit
b2b23ffb
authored
22 years ago
by
Mark Woolrich
Browse files
Options
Downloads
Patches
Plain Diff
*** empty log message ***
parent
cb9f3804
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
log.cc
+3
-3
3 additions, 3 deletions
log.cc
log.h
+26
-20
26 additions, 20 deletions
log.h
time_tracer.cc
+4
-2
4 additions, 2 deletions
time_tracer.cc
time_tracer.h
+37
-5
37 additions, 5 deletions
time_tracer.h
with
70 additions
and
30 deletions
log.cc
+
3
−
3
View file @
b2b23ffb
...
...
@@ -10,10 +10,10 @@
namespace
Utilities
{
Log
ger
*
LogSingleton
::
logger
=
NULL
;
Log
*
LogSingleton
::
logger
=
NULL
;
int
LogSingleton
::
count
=
0
;
void
Log
ger
::
makeDir
(
const
string
&
pdirname
,
const
string
&
plogfilename
,
bool
pstream_to_logfile
,
bool
pstream_to_cout
)
void
Log
::
makeDir
(
const
string
&
pdirname
,
const
string
&
plogfilename
,
bool
pstream_to_logfile
,
bool
pstream_to_cout
)
{
if
(
logEstablished
)
{
...
...
@@ -58,7 +58,7 @@ namespace Utilities {
logEstablished
=
true
;
}
void
Log
ger
::
setDir
(
const
string
&
pdirname
,
const
string
&
plogfilename
,
bool
pstream_to_logfile
,
bool
pstream_to_cout
)
void
Log
::
setDir
(
const
string
&
pdirname
,
const
string
&
plogfilename
,
bool
pstream_to_logfile
,
bool
pstream_to_cout
)
{
if
(
logEstablished
)
{
...
...
This diff is collapsed.
Click to expand it.
log.h
+
26
−
20
View file @
b2b23ffb
...
...
@@ -4,6 +4,14 @@
Copyright (C) 1999-2000 University of Oxford */
/* The Log class allows for instantiation of more than one Log
either sharing directories or not. However, Logs can not share log files.
Or you can work with the LogSIngleton class.
A Log can open new logfiles in the same log directory or start on an
entirely new directory. You can stream directly to a Log with flags
determining streaming to the Logfile and/or cout. */
/* CCOPYRIGHT */
#if !defined(log_h)
...
...
@@ -29,9 +37,9 @@ namespace Utilities{
return
string
(
strc
);
}
class
Log
ger
;
class
Log
;
template
<
class
t
>
Log
ger
&
operator
<<
(
Log
ger
&
log
,
const
t
&
obj
)
template
<
class
t
>
Log
&
operator
<<
(
Log
&
log
,
const
t
&
obj
)
{
if
(
log
.
stream_to_logfile
)
log
.
logfileout
<<
obj
;
...
...
@@ -42,12 +50,12 @@ namespace Utilities{
return
log
;
}
class
Log
ger
class
Log
{
public:
Log
ger
()
:
logEstablished
(
false
)
{}
Log
()
:
logEstablished
(
false
)
{}
Log
ger
(
const
string
&
pdirname
,
const
string
&
plogfilename
=
"logfile"
,
bool
pstream_to_logfile
=
true
,
bool
pstream_to_cout
=
false
,
bool
makedir
=
true
)
:
logEstablished
(
false
)
Log
(
const
string
&
pdirname
,
const
string
&
plogfilename
=
"logfile"
,
bool
pstream_to_logfile
=
true
,
bool
pstream_to_cout
=
false
,
bool
makedir
=
true
)
:
logEstablished
(
false
)
{
if
(
makedir
)
makeDir
(
pdirname
,
plogfilename
,
pstream_to_logfile
,
pstream_to_cout
);
...
...
@@ -55,9 +63,9 @@ namespace Utilities{
setDir
(
pdirname
,
plogfilename
,
pstream_to_logfile
,
pstream_to_cout
);
}
~
Log
ger
()
{
logfileout
.
close
();
}
~
Log
()
{
logfileout
.
close
();
}
/** Need to call makeDir or setDir before Log
ger
can be used */
/** Need to call makeDir or setDir before Log can be used */
/** Makes a directory to place results into:
keeps adding "+" to pdirname until unique directory is made. */
...
...
@@ -82,7 +90,7 @@ namespace Utilities{
/** stream_to_cout and stream_to_logfile respectively */
/** use like a normal ostream, e.g. log.str() << "hello" << endl */
/** NOTE: can simply stream straight to Log instead, e.g. log << "hello" << endl */
Log
ger
&
str
();
Log
&
str
();
/** sets whether or not you stream to cout */
void
set_stream_to_cout
(
bool
in
=
true
)
{
stream_to_cout
=
in
;
}
...
...
@@ -101,8 +109,8 @@ namespace Utilities{
private
:
const
Log
ger
&
operator
=
(
Log
ger
&
);
Log
ger
(
Log
ger
&
);
const
Log
&
operator
=
(
Log
&
);
Log
(
Log
&
);
string
dir
;
ofstream
logfileout
;
...
...
@@ -114,14 +122,14 @@ namespace Utilities{
bool
stream_to_cout
;
template
<
class
t
>
friend
Log
ger
&
operator
<<
(
Log
ger
&
log
,
const
t
&
obj
);
friend
Log
&
operator
<<
(
Log
&
log
,
const
t
&
obj
);
};
class
LogSingleton
{
public:
static
Log
ger
&
getInstance
();
static
Log
&
getInstance
();
~
LogSingleton
()
{
delete
logger
;
}
...
...
@@ -134,22 +142,20 @@ namespace Utilities{
const
LogSingleton
&
operator
=
(
LogSingleton
&
);
LogSingleton
(
LogSingleton
&
);
static
Log
ger
*
logger
;
static
Log
*
logger
;
static
int
count
;
};
typedef
LogSingleton
Log
;
inline
Logger
&
LogSingleton
::
getInstance
(){
inline
Log
&
LogSingleton
::
getInstance
(){
if
(
logger
==
NULL
)
logger
=
new
Log
ger
();
logger
=
new
Log
();
return
*
logger
;
}
inline
void
Log
ger
::
setLogFile
(
const
string
&
plogfilename
)
{
inline
void
Log
::
setLogFile
(
const
string
&
plogfilename
)
{
if
(
!
logEstablished
)
{
...
...
@@ -172,7 +178,7 @@ namespace Utilities{
logEstablished
=
true
;
}
inline
Log
ger
&
Log
ger
::
str
()
{
inline
Log
&
Log
::
str
()
{
if
(
!
logEstablished
)
{
...
...
@@ -182,7 +188,7 @@ namespace Utilities{
return
*
this
;
}
inline
const
string
Log
ger
::
appendDir
(
const
string
&
filename
)
const
{
inline
const
string
Log
::
appendDir
(
const
string
&
filename
)
const
{
if
(
!
logEstablished
)
{
...
...
This diff is collapsed.
Click to expand it.
time_tracer.cc
+
4
−
2
View file @
b2b23ffb
...
...
@@ -15,10 +15,12 @@
namespace
Utilities
{
bool
Time_Tracer
::
debug
=
false
;
bool
Time_Tracer
::
instantstack
=
false
;
bool
Time_Tracer
::
runningstack
=
false
;
bool
Time_Tracer
::
timingon
=
false
;
unsigned
int
Time_Tracer
::
pad
=
0
;
set
<
TimingFunction
*
,
TimingFunction
::
comparer
>
Time_Tracer
::
timingFunctions
;
set
<
TimingFunction
*
,
TimingFunction
::
comparer_name
>
Time_Tracer
::
timingFunctions
;
stack
<
string
>
Time_Tracer
::
stk
;
}
...
...
This diff is collapsed.
Click to expand it.
time_tracer.h
+
37
−
5
View file @
b2b23ffb
...
...
@@ -14,6 +14,7 @@
#include
<string>
#include
<time.h>
#include
<set>
#include
<stack>
namespace
Utilities
{
...
...
@@ -80,14 +81,18 @@ namespace Utilities{
public:
Time_Tracer
(
char
*
str
)
{
if
(
debug
)
if
(
instantstack
)
{
tmp
=
""
;
pad
++
;
for
(
unsigned
int
i
=
0
;
i
<
pad
;
i
++
)
tmp
=
tmp
+
" "
;
cout
<<
tmp
<<
str
<<
endl
;
stk
.
push
(
string
(
str
));
if
(
runningstack
)
cout
<<
tmp
<<
str
<<
endl
;
}
if
(
timingon
)
{
...
...
@@ -110,7 +115,10 @@ namespace Utilities{
virtual
~
Time_Tracer
()
{
if
(
debug
&&
pad
>
0
)
if
(
instantstack
)
stk
.
pop
();
if
(
runningstack
&&
pad
>
0
)
{
cout
<<
tmp
<<
"finished"
<<
endl
;
pad
--
;
...
...
@@ -119,6 +127,7 @@ namespace Utilities{
{
timingFunction
->
end
();
}
}
static
void
dump_times
(
const
string
&
dir
)
...
...
@@ -134,14 +143,37 @@ namespace Utilities{
out
.
close
();
}
static
void
setdebugon
()
{
debug
=
true
;}
static
void
dump_instant_stack
()
{
// tmp stack to put values into for restoring stack after outputting
stack
<
string
>
tmpstk
;
while
(
!
stk
.
empty
())
{
cout
<<
stk
.
top
()
<<
endl
;
tmpstk
.
push
(
stk
.
top
());
stk
.
pop
();
}
while
(
!
tmpstk
.
empty
())
{
stk
.
push
(
tmpstk
.
top
());
tmpstk
.
pop
();
}
}
static
void
setinstantstackon
()
{
instantstack
=
true
;}
static
void
setrunningstackon
()
{
runningstack
=
true
;}
static
void
settimingon
()
{
timingon
=
true
;}
protected
:
static
bool
debug
;
static
bool
instantstack
;
static
bool
runningstack
;
static
bool
timingon
;
static
unsigned
int
pad
;
static
set
<
TimingFunction
*
,
TimingFunction
::
comparer_name
>
timingFunctions
;
static
stack
<
string
>
stk
;
string
tmp
;
TimingFunction
*
timingFunction
;
...
...
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