MoFEM printing extra info

42 views
Skip to first unread message
Assigned to lik...@wp.pl by me

Preslav Aleksandrov

unread,
Oct 4, 2021, 5:26:15 PM10/4/21
to MoFEM Q&A
Hello,

How can I stop MoFEM from printing the extra info before my output?
See attached.
mofem.png

Lukasz Kaczmraczyk

unread,
Oct 4, 2021, 5:34:14 PM10/4/21
to MoFEM Q&A
Hi,

If you like to control output in MoFEM, look here,

where level of noisiness are controlled by

so if you do
./porgram -log_sl warning
warnings and errors are printed, if you do
./porgram -log_sl error 
only errors are printed. 

Default severity level is "infrom"

You make code quite from teminal level,
./porgram 2>&1 > /dev/null

Regards,
L.

Preslav Aleksandrov

unread,
Oct 4, 2021, 5:59:11 PM10/4/21
to MoFEM Q&A
And is there a way to set the severity to warning from cpp instead of terminal?

Lukasz Kaczmraczyk

unread,
Oct 4, 2021, 6:12:50 PM10/4/21
to MoFEM Q&A
That should do

logging::core::get()->set_filter(MoFEM::LogKeywords::severity >= LogManager::warning);

L.

Preslav Aleksandrov

unread,
Oct 5, 2021, 4:56:47 AM10/5/21
to MoFEM Q&A
Can I post my code here? I did exactly this last night, but the the info was still printed.

Lukasz Kaczmraczyk

unread,
Oct 5, 2021, 5:48:00 AM10/5/21
to MoFEM Q&A
Hi, 

I just realized, that when you set that option before initialization, is reset at initialization to default "inform" verbosity level. Sorry, my mistake. What I suggested will work after initalisation, but it has less use for you.

Try this,
char mumps_options[]  = {"-log_sl warning"}
PetscOptionsInsertString(NULL, mumps_options);

However, a much better solution is to create a param file, and put options which you wish to be default there, for example into param_file.petsc. Then in the input param file, you put "-log_sl warning".

const char param_file[] = "param_file.petsc";
MoFEM::Core::Initialize(&argc, &argv, param_file, help);

L.



Preslav Aleksandrov

unread,
Oct 5, 2021, 5:57:21 AM10/5/21
to MoFEM Q&A
Great that worked like a charm!
What is the recommended way of printing warnings to the terminal?

Lukasz Kaczmraczyk

unread,
Oct 5, 2021, 6:00:15 AM10/5/21
to MoFEM Q&A

What do you mean?  

Preslav Aleksandrov

unread,
Oct 5, 2021, 6:02:30 AM10/5/21
to MoFEM Q&A
I know there is a mofem way of printing messages but I don't remember what it is exactly. I don't want to use just cout.

Lukasz Kaczmraczyk

unread,
Oct 5, 2021, 6:19:40 AM10/5/21
to MoFEM Q&A
Ach, look here as an example,

The best practice is to create own channel, 

auto core_log = logging::core::get();
core_log->add_sink(
      LogManager::createSink(LogManager::getStrmWorld(), "EXAMPLE"));
LogManager::setLog("MYCHANNE");
MOFEM_LOG_TAG("MYCHANNEL", "example")

Then you can print to it as follows,

MOFEM_LOG("MYCHANNEL", Sev::infrom") << "Hellow world";

Note that then you can do another thing, change the way how you print, and were, e.g. to file, or some special terminal, etc. For more details see,

L.

Lukasz Kaczmraczyk

unread,
Oct 5, 2021, 6:45:04 AM10/5/21
to MoFEM Q&A
Small fix,
auto core_log = logging::core::get();
core_log->add_sink(
      LogManager::createSink(LogManager::getStrmWorld(), "MYCHANNE"));
LogManager::setLog("MYCHANNE");
MOFEM_LOG_TAG("MYCHANNEL", "example")

Reply all
Reply to author
Forward
0 new messages