#include <thread>
#include <chrono>
BOOST_LOG_SCOPED_THREAD_ATTR("Timeline", attrs::timer());
MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Hello, world!";
std::this_thread::sleep_for(std::chrono::milliseconds(300));
MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Hello, second time world!";
}
MOFEM_LOG(
"SYNC", Sev::verbose) <<
"Hello, sync!";
MOFEM_LOG(
"SYNC", Sev::verbose) <<
"Hello again, sync!";
}
MOFEM_LOG(
"SYNC", Sev::verbose) <<
"Hello, sync!";
MOFEM_LOG(
"SYNC", Sev::verbose) <<
"Hello again, sync!";
}
static char help[] =
"...\n\n";
int main(
int argc,
char *argv[]) {
try {
CHKERR PetscPrintf(PETSC_COMM_WORLD,
"\nTesting logging for obsolete way of printing "
"messages\nnext line\nnext line\n\n");
CHKERR PetscPrintf(PETSC_COMM_WORLD,
"Ala have ");
CHKERR PetscPrintf(PETSC_COMM_WORLD,
"a ");
CHKERR PetscPrintf(PETSC_COMM_WORLD,
"cat\n");
CHKERR PetscPrintf(PETSC_COMM_WORLD,
"WARNING\n");
{
MOFEM_LOG(
"WORLD", Sev::error) <<
"Hello, self error!";
MOFEM_LOG(
"WORLD", Sev::warning) <<
"Hello, self warning!";
MOFEM_LOG(
"WORLD", Sev::inform) <<
"Hello, self inform!";
MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Hello, self verbose!";
MOFEM_LOG(
"WORLD", Sev::noisy) <<
"Hello, self noisy!";
}
{
MOFEM_LOG_C(
"WORLD", Sev::inform,
"%s %d %d %d",
"Hello C, self error!",
1, 2, 3);
}
{
}
auto core_log = logging::core::get();
core_log->add_sink(
boost::make_shared<std::ofstream>("log0.log"), "ATOM_TEST"));
logging::add_file_log(keywords::file_name = "log1.log",
keywords::filter =
MoFEM::LogKeywords::channel == "ATOM_TEST");
auto backend = boost::make_shared<sinks::text_ostream_backend>();
backend->add_stream(boost::make_shared<std::ofstream>("log2.log"));
auto sink = boost::make_shared<LogManager::SinkType>(backend);
sink->set_filter((expr::has_attr(MoFEM::LogKeywords::channel) &&
MoFEM::LogKeywords::channel == "ATOM_TEST"));
core_log->add_sink(sink);
MOFEM_LOG(
"ATOM_TEST", Sev::inform) <<
"Test atom test channel";
}
}