Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
c573f43c
There was an error fetching the commit references. Please try again later.
Commit
c573f43c
authored
6 years ago
by
Jakub Klinkovský
Browse files
Options
Downloads
Patches
Plain Diff
Moved stuff from Logger.cpp to Logger_impl.h
parent
35b0e105
No related branches found
No related tags found
1 merge request
!22
Header only
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/TNL/CMakeLists.txt
+0
-1
0 additions, 1 deletion
src/TNL/CMakeLists.txt
src/TNL/Logger.cpp
+0
-57
0 additions, 57 deletions
src/TNL/Logger.cpp
src/TNL/Logger.h
+6
-6
6 additions, 6 deletions
src/TNL/Logger.h
src/TNL/Logger_impl.h
+60
-17
60 additions, 17 deletions
src/TNL/Logger_impl.h
with
66 additions
and
81 deletions
src/TNL/CMakeLists.txt
+
0
−
1
View file @
c573f43c
...
...
@@ -39,7 +39,6 @@ set( headers
set
(
common_SOURCES
FileName.cpp
Object.cpp
Logger.cpp
String.cpp
Timer.cpp
)
...
...
This diff is collapsed.
Click to expand it.
src/TNL/Logger.cpp
deleted
100644 → 0
+
0
−
57
View file @
35b0e105
/***************************************************************************
Logger.cpp - description
-------------------
begin : 2007/08/22
copyright : (C) 2007 by Tomas Oberhuber
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/* See Copyright Notice in tnl/Copyright */
#include
<iomanip>
#include
<TNL/Logger.h>
#include
<TNL/Devices/CudaDeviceInfo.h>
#include
<TNL/Devices/SystemInfo.h>
namespace
TNL
{
Logger
::
Logger
(
int
_width
,
std
::
ostream
&
_stream
)
:
width
(
_width
),
stream
(
_stream
)
{
}
void
Logger
::
writeHeader
(
const
String
&
title
)
{
int
fill
=
stream
.
fill
();
int
titleLength
=
title
.
getLength
();
stream
<<
"+"
<<
std
::
setfill
(
'-'
)
<<
std
::
setw
(
width
)
<<
"+"
<<
std
::
endl
;
stream
<<
"|"
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
width
)
<<
"|"
<<
std
::
endl
;
stream
<<
"|"
<<
std
::
setw
(
width
/
2
+
titleLength
/
2
)
<<
title
<<
std
::
setw
(
width
/
2
-
titleLength
/
2
)
<<
"|"
<<
std
::
endl
;
stream
<<
"|"
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
width
)
<<
"|"
<<
std
::
endl
;
stream
<<
"+"
<<
std
::
setfill
(
'-'
)
<<
std
::
setw
(
width
)
<<
"+"
<<
std
::
endl
;
stream
.
fill
(
fill
);
}
void
Logger
::
writeSeparator
()
{
int
fill
=
stream
.
fill
();
stream
<<
"+"
<<
std
::
setfill
(
'-'
)
<<
std
::
setw
(
width
)
<<
"+"
<<
std
::
endl
;
stream
.
fill
(
fill
);
}
bool
Logger
::
writeSystemInformation
(
const
Config
::
ParameterContainer
&
parameters
)
{
Devices
::
SystemInfo
::
writeDeviceInfo
(
*
this
);
if
(
parameters
.
getParameter
<
String
>
(
"device"
)
==
"cuda"
)
Devices
::
CudaDeviceInfo
::
writeDeviceInfo
(
*
this
);
return
true
;
}
void
Logger
::
writeCurrentTime
(
const
char
*
label
)
{
writeParameter
<
String
>
(
label
,
Devices
::
SystemInfo
::
getCurrentTime
()
);
}
}
// namespace TNL
This diff is collapsed.
Click to expand it.
src/TNL/Logger.h
+
6
−
6
View file @
c573f43c
...
...
@@ -11,6 +11,7 @@
#pragma once
#include
<ostream>
#include
<TNL/Config/ParameterContainer.h>
namespace
TNL
{
...
...
@@ -18,15 +19,15 @@ namespace TNL {
/// Creates calculations log in the form of a table.
class
Logger
{
public:
public:
/////
/// \brief Basic constructor.
///
/// \param _width Integer that defines the width of the log.
/// \param _stream Defines output stream where the log will be printed out.
Logger
(
int
_width
,
std
::
ostream
&
_stream
);
Logger
(
int
width
,
std
::
ostream
&
stream
)
:
width
(
width
),
stream
(
stream
)
{}
/////
/// \brief Creates header in given log.
...
...
@@ -76,8 +77,7 @@ class Logger
const
ParameterType
&
value
,
int
parameterLevel
=
0
);
protected:
protected
:
/// \brief Integer defining the width of the log.
int
width
;
...
...
This diff is collapsed.
Click to expand it.
src/TNL/Logger_impl.h
+
60
−
17
View file @
c573f43c
...
...
@@ -13,29 +13,72 @@
#include
<sstream>
#include
<iomanip>
#include
<TNL/Logger.h>
#include
<TNL/Devices/CudaDeviceInfo.h>
#include
<TNL/Devices/SystemInfo.h>
namespace
TNL
{
template
<
typename
ParameterType
>
void
Logger
::
writeParameter
(
const
String
&
label
,
const
String
&
parameterName
,
const
Config
::
ParameterContainer
&
parameters
,
int
parameterLevel
)
inline
void
Logger
::
writeHeader
(
const
String
&
title
)
{
const
int
fill
=
stream
.
fill
();
const
int
titleLength
=
title
.
getLength
();
stream
<<
"+"
<<
std
::
setfill
(
'-'
)
<<
std
::
setw
(
width
)
<<
"+"
<<
std
::
endl
;
stream
<<
"|"
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
width
)
<<
"|"
<<
std
::
endl
;
stream
<<
"|"
<<
std
::
setw
(
width
/
2
+
titleLength
/
2
)
<<
title
<<
std
::
setw
(
width
/
2
-
titleLength
/
2
)
<<
"|"
<<
std
::
endl
;
stream
<<
"|"
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
width
)
<<
"|"
<<
std
::
endl
;
stream
<<
"+"
<<
std
::
setfill
(
'-'
)
<<
std
::
setw
(
width
)
<<
"+"
<<
std
::
endl
;
stream
.
fill
(
fill
);
}
inline
void
Logger
::
writeSeparator
()
{
const
int
fill
=
stream
.
fill
();
stream
<<
"+"
<<
std
::
setfill
(
'-'
)
<<
std
::
setw
(
width
)
<<
"+"
<<
std
::
endl
;
stream
.
fill
(
fill
);
}
inline
bool
Logger
::
writeSystemInformation
(
const
Config
::
ParameterContainer
&
parameters
)
{
Devices
::
SystemInfo
::
writeDeviceInfo
(
*
this
);
if
(
parameters
.
getParameter
<
String
>
(
"device"
)
==
"cuda"
)
Devices
::
CudaDeviceInfo
::
writeDeviceInfo
(
*
this
);
return
true
;
}
inline
void
Logger
::
writeCurrentTime
(
const
char
*
label
)
{
writeParameter
<
String
>
(
label
,
Devices
::
SystemInfo
::
getCurrentTime
()
);
}
template
<
typename
T
>
void
Logger
::
writeParameter
(
const
String
&
label
,
const
String
&
parameterName
,
const
Config
::
ParameterContainer
&
parameters
,
int
parameterLevel
)
{
stream
<<
"| "
;
int
i
;
for
(
i
=
0
;
i
<
parameterLevel
;
i
++
)
stream
<<
" "
;
std
::
stringstream
str
;
str
<<
parameters
.
getParameter
<
ParameterType
>
(
parameterName
);
stream
<<
label
<<
std
::
setw
(
width
-
label
.
getLength
()
-
parameterLevel
-
3
)
<<
str
.
str
()
<<
" |"
<<
std
::
endl
;
str
<<
parameters
.
getParameter
<
T
>
(
parameterName
);
stream
<<
label
<<
std
::
setw
(
width
-
label
.
getLength
()
-
parameterLevel
-
3
)
<<
str
.
str
()
<<
" |"
<<
std
::
endl
;
}
template
<
typename
ParameterType
>
void
Logger
::
writeParameter
(
const
String
&
label
,
const
ParameterType
&
value
,
int
parameterLevel
)
template
<
typename
T
>
void
Logger
::
writeParameter
(
const
String
&
label
,
const
T
&
value
,
int
parameterLevel
)
{
stream
<<
"| "
;
int
i
;
...
...
@@ -43,9 +86,9 @@ void Logger :: writeParameter( const String& label,
stream
<<
" "
;
std
::
stringstream
str
;
str
<<
value
;
stream
<<
label
<<
std
::
setw
(
width
-
label
.
getLength
()
-
parameterLevel
-
3
)
<<
str
.
str
()
<<
" |"
<<
std
::
endl
;
}
;
stream
<<
label
<<
std
::
setw
(
width
-
label
.
getLength
()
-
parameterLevel
-
3
)
<<
str
.
str
()
<<
" |"
<<
std
::
endl
;
}
}
// namespace TNL
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