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,
"Ala have ");
81 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"a ");
82 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"cat\n");
83
84 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"WARNING\n");
85
86
88 {
89 MOFEM_LOG(
"WORLD", Sev::error) <<
"Hello, self error!";
90 MOFEM_LOG(
"WORLD", Sev::warning) <<
"Hello, self warning!";
91 MOFEM_LOG(
"WORLD", Sev::inform) <<
"Hello, self inform!";
92 MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Hello, self verbose!";
93 MOFEM_LOG(
"WORLD", Sev::noisy) <<
"Hello, self noisy!";
94 }
95
96 {
97 MOFEM_LOG_C(
"WORLD", Sev::inform,
"%s %d %d %d",
"Hello C, self error!",
98 1, 2, 3);
99 }
100
101 {
105 }
106
107
108 auto core_log = logging::core::get();
109 core_log->add_sink(
112
113
115 boost::make_shared<std::ofstream>("log0.log"), "ATOM_TEST"));
116
117
118 logging::add_file_log(keywords::file_name = "log1.log",
119 keywords::filter =
120 MoFEM::LogKeywords::channel == "ATOM_TEST");
121
122
123 auto backend = boost::make_shared<sinks::text_ostream_backend>();
124 backend->add_stream(boost::make_shared<std::ofstream>("log2.log"));
125 auto sink = boost::make_shared<LogManager::SinkType>(backend);
126 sink->set_filter((expr::has_attr(MoFEM::LogKeywords::channel) &&
127 MoFEM::LogKeywords::channel == "ATOM_TEST"));
128 core_log->add_sink(sink);
129
131 MOFEM_LOG(
"ATOM_TEST", Sev::inform) <<
"Test atom test channel";
132
133 FILE *file = std::fopen("log.txt", "w");
134 if (file == nullptr) {
136 "Failed to open file for logging");
137 }
138
142
143 MOFEM_LOG(
"WRITE_TEST", Sev::inform) <<
"Writing to file";
144
146
147
148 std::fclose(file);
149
150
151 }
153
155}
#define MOFEM_LOG_FILE_SYNCHRONISE(comm, fd)
Synchronise "SYNC" channel.
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
#define MOFEM_LOG_C(channel, severity, format,...)
#define CATCH_ERRORS
Catch errors.
@ MOFEM_OPERATION_UNSUCCESSFUL
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 > getStrmSync()
Get the strm sync object.
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.