Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Dmitri Naumov
ogs
Commits
36c4a81a
Commit
36c4a81a
authored
5 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
Set log pattern for mpi
parent
4bb167c1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Applications/CLI/ogs.cpp
+7
-5
7 additions, 5 deletions
Applications/CLI/ogs.cpp
BaseLib/Logging.cpp
+12
-0
12 additions, 0 deletions
BaseLib/Logging.cpp
Tests/testrunner.cpp
+16
-20
16 additions, 20 deletions
Tests/testrunner.cpp
with
35 additions
and
25 deletions
Applications/CLI/ogs.cpp
+
7
−
5
View file @
36c4a81a
...
...
@@ -121,7 +121,8 @@ int main(int argc, char* argv[])
std
::
cout
.
setf
(
std
::
ios
::
unitbuf
);
}
logog_setup
.
setLevel
(
log_level_arg
.
getValue
());
BaseLib
::
setConsoleLogLevel
(
log_level_arg
.
getValue
());
spdlog
::
set_pattern
(
"%^%l:%$ %v"
);
INFO
(
"This is OpenGeoSys-6 version {:s}."
,
GitInfoLib
::
GitInfo
::
ogs_version
);
...
...
@@ -166,10 +167,11 @@ int main(int argc, char* argv[])
controller
->
Initialize
(
&
argc
,
&
argv
,
1
);
vtkMPIController
::
SetGlobalController
(
controller
);
logog_setup
.
setFormatter
(
std
::
make_unique
<
BaseLib
::
TemplateLogogFormatterSuppressedGCC
<
TOPIC_LEVEL_FLAG
|
TOPIC_FILE_NAME_FLAG
|
TOPIC_LINE_NUMBER_FLAG
>>
());
{
// Can be called only after MPI_INIT.
int
mpi_rank
;
MPI_Comm_rank
(
PETSC_COMM_WORLD
,
&
mpi_rank
);
spdlog
::
set_pattern
(
fmt
::
format
(
"[{}] %^%l:%$ %v"
,
mpi_rank
));
}
#endif
run_time
.
start
();
...
...
This diff is collapsed.
Click to expand it.
BaseLib/Logging.cpp
+
12
−
0
View file @
36c4a81a
...
...
@@ -10,13 +10,25 @@
*/
#include
"Logging.h"
#include
<spdlog/sinks/stdout_color_sinks.h>
#include
<map>
#ifdef USE_PETSC
#include
<mpi.h>
#include
<petscsys.h>
#endif
#include
"Error.h"
namespace
BaseLib
{
#ifdef USE_PETSC
std
::
shared_ptr
<
spdlog
::
logger
>
console
=
spdlog
::
stdout_color_mt
(
"ogs"
);
#else // USE_PETSC
std
::
shared_ptr
<
spdlog
::
logger
>
console
=
spdlog
::
stdout_color_st
(
"ogs"
);
#endif // USE_PETSC
void
setConsoleLogLevel
(
std
::
string
const
&
level_string
)
{
...
...
This diff is collapsed.
Click to expand it.
Tests/testrunner.cpp
+
16
−
20
View file @
36c4a81a
...
...
@@ -12,15 +12,13 @@
*
*/
// ** INCLUDES **
#include
<clocale>
#include
"gtest/gtest.h"
#include
"Applications/ApplicationsLib/LogogSetup.h"
#include
"Applications/ApplicationsLib/LinearSolverLibrarySetup.h"
#include
"BaseLib/Error.h"
#include
"BaseLib/Logging.h"
#include
"NumLib/DOF/GlobalMatrixProviders.h"
#include
"
BaseLib/TemplateLogogFormatterSuppressedGCC
.h"
#include
"
gtest/gtest
.h"
#ifdef OGS_BUILD_GUI
#include
<QCoreApplication>
...
...
@@ -51,24 +49,22 @@ int main(int argc, char* argv[])
QCoreApplication
app
(
argc
,
argv
,
false
);
#endif
// Attention: Order matters!
// logog_setup must be created first, then the linear_solver_library_setup,
// because destruction order is the reverse of the creation order and the
// destructor of linear_solver_library_setup might print log messages.
// The methods on logog_setup must be called after the construction of
// linear_solver_library_setup since they require, e.g., that MPI_Init()
// has been called before.
ApplicationsLib
::
LogogSetup
logog_setup
;
ApplicationsLib
::
LinearSolverLibrarySetup
linear_solver_library_setup
(
argc
,
argv
);
logog_setup
.
setFormatter
(
std
::
make_unique
<
BaseLib
::
TemplateLogogFormatterSuppressedGCC
<
TOPIC_LEVEL_FLAG
|
TOPIC_FILE_NAME_FLAG
|
TOPIC_LINE_NUMBER_FLAG
>>
());
logog_setup
.
setLevel
(
logLevel
);
BaseLib
::
setConsoleLogLevel
(
logLevel
);
spdlog
::
set_pattern
(
"%^%l:%$ %v"
);
spdlog
::
set_error_handler
([](
const
std
::
string
&
msg
)
{
std
::
cerr
<<
"spdlog error: "
<<
msg
<<
std
::
endl
;
OGS_FATAL
(
"spdlog logger error occured."
);
});
#ifdef USE_PETSC
{
// Can be called only after MPI_INIT.
int
mpi_rank
;
MPI_Comm_rank
(
PETSC_COMM_WORLD
,
&
mpi_rank
);
spdlog
::
set_pattern
(
fmt
::
format
(
"[{}] %^%l:%$ %v"
,
mpi_rank
));
}
#endif
try
{
...
...
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