Appendix

Slic Application Code Example

Below is the complete Slic Application Code Example presented in the Getting Started with Slic section. The code can be found in the Axom source code under src/axom/slic/examples/basic/logging.cpp.

 1// SPHINX_SLIC_INCLUDES_BEGIN
 2// Slic includes
 3#include "axom/slic.hpp"
 4// SPHINX_SLIC_INCLUDES_END
 5
 6using namespace axom;
 7
 8//------------------------------------------------------------------------------
 9int main(int AXOM_UNUSED_PARAM(argc), char** AXOM_UNUSED_PARAM(argv))
10{
11  // SPHINX_SLIC_INIT_BEGIN
12
13  slic::initialize();
14
15  // SPHINX_SLIC_INIT_END
16
17  slic::disableAbortOnError();
18
19  // SPHINX_SLIC_FORMAT_MSG_BEGIN
20
21  std::string format = std::string("<TIMESTAMP>\n") +
22    std::string("[ <LEVEL> <TAG>]: <MESSAGE> \n") + std::string("FILE=<FILE>\n") +
23    std::string("LINE=<LINE>\n\n");
24
25  // SPHINX_SLIC_FORMAT_MSG_END
26
27  // SPHINX_SLIC_SET_SEVERITY_BEGIN
28
29  slic::setLoggingMsgLevel(slic::message::Debug);
30
31  // SPHINX_SLIC_SET_SEVERITY_END
32
33  // SPHINX_SLIC_SET_STREAM_BEGIN
34  slic::addStreamToAllMsgLevels(new slic::GenericOutputStream(&std::cout, format));
35
36  // SPHINX_SLIC_SET_STREAM_END
37
38  // SPHINX_SLIC_SET_TAGGED_STREAM_BEGIN
39  slic::addStreamToTag(new slic::GenericOutputStream(&std::cout, format), "myTag");
40
41  // SPHINX_SLIC_SET_TAGGED_STREAM_END
42
43  // SPHINX_SLIC_LOG_MESSAGES_BEGIN
44
45  SLIC_DEBUG("Here is a debug message!");
46  SLIC_INFO("Here is an info mesage!");
47  SLIC_WARNING("Here is a warning!");
48  SLIC_ERROR("Here is an error message!");
49  SLIC_INFO_TAGGED("Here is a message for tagged streams with tag 'myTag'!", "myTag");
50
51  // SPHINX_SLIC_LOG_MESSAGES_END
52
53  // SPHINX_SLIC_FINALIZE_BEGIN
54
55  slic::finalize();
56
57  // SPHINX_SLIC_FINALIZE_END
58
59  return 0;
60}

axom::utilities::processAbort()

The axom::utilities::processAbort() function gracefully aborts the application by:

  1. Calling abort() if it is a serial application.

  2. Calls MPI_Abort() if the Axom Toolkit is compiled with MPI and the application has initialized MPI, i.e., it’s a distributed MPI application.