64 {
65
67
68 try {
69
70 moab::Core mb_instance;
71 moab::Interface &moab = mb_instance;
72
75
76 CHKERR PetscPrintf(PETSC_COMM_WORLD,
77 "\nTesting logging for obsolete way of printing "
78 "messages\nnext line\nnext line\n\n");
79
80 CHKERR PetscPrintf(PETSC_COMM_WORLD,
81 "Ala have ");
82 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"a ");
83 CHKERR PetscPrintf(PETSC_COMM_WORLD,
84 "cat\n");
85
86 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"WARNING\n");
87
88
90 {
91 MOFEM_LOG(
"WORLD", Sev::error) <<
"Hello, self error!";
92 MOFEM_LOG(
"WORLD", Sev::warning) <<
"Hello, self warning!";
93 MOFEM_LOG(
"WORLD", Sev::inform) <<
"Hello, self inform!";
94 MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Hello, self verbose!";
95 MOFEM_LOG(
"WORLD", Sev::noisy) <<
"Hello, self noisy!";
96 }
97
98 {
99 MOFEM_LOG_C(
"WORLD", Sev::inform,
"%s %d %d %d",
"Hello C, self error!",
100 1, 2, 3);
101 }
102
103 {
107 }
108
109
110 auto core_log = logging::core::get();
111 core_log->add_sink(
114
115
117 boost::make_shared<std::ofstream>("log0.log"), "ATOM_TEST"));
118
119
120 logging::add_file_log(keywords::file_name = "log1.log",
121 keywords::filter =
122 MoFEM::LogKeywords::channel == "ATOM_TEST");
123
124
125 auto backend = boost::make_shared<sinks::text_ostream_backend>();
126 backend->add_stream(boost::make_shared<std::ofstream>("log2.log"));
127 auto sink = boost::make_shared<LogManager::SinkType>(backend);
128 sink->set_filter((expr::has_attr(MoFEM::LogKeywords::channel) &&
129 MoFEM::LogKeywords::channel == "ATOM_TEST"));
130 core_log->add_sink(sink);
131
132
134 MOFEM_LOG(
"ATOM_TEST", Sev::inform) <<
"Test atom test channel";
135
136
137
138 }
140
142}
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
#define MOFEM_LOG_C(channel, severity, format,...)
#define CATCH_ERRORS
Catch errors.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
MoFEMErrorCode log_fun1()
MoFEMErrorCode log_fun2()
virtual MPI_Comm & get_comm() const =0
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.