/* ///////////////////////////////////////////////////////////////////////// * File: examples/cpp/inserters/example.cpp.inserter.hostid/example.cpp.inserter.hostid.cpp * * Purpose: C++ example program for Pantheios. Demonstrates: * * - use of Pantheios inserter for host ids * - use of pantheios::logputs() in bail-out conditions * * Created: 15th April 2008 * Updated: 2nd December 2010 * * www: http://www.pantheios.org/ * * License: This source code is placed into the public domain 2006 * by Synesis Software Pty Ltd. There are no restrictions * whatsoever to your use of the software. * * This software is provided "as is", and any warranties, * express or implied, of any kind and for any purpose, are * disclaimed. * * ////////////////////////////////////////////////////////////////////// */ /* Pantheios Header Files */ #include // Pantheios C++ main header #include // for pantheios::hostId /* Standard C/C++ Header Files */ #include // for std::exception #include // for std::bad_alloc #include // for std::string #include // for exit codes #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION # if defined(STLSOFT_COMPILER_IS_MSVC) # pragma warning(disable : 4702) # endif /* compiler */ #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */ /* ////////////////////////////////////////////////////////////////////// */ /* Define the stock front-end process identity, so that it links when using * fe.N, fe.simple, etc. */ PANTHEIOS_EXTERN_C const PAN_CHAR_T PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("example.cpp.inserter.hostid"); /* ////////////////////////////////////////////////////////////////////// */ #define PSTR(x) PANTHEIOS_LITERAL_STRING(x) /* ////////////////////////////////////////////////////////////////////// */ int main() { try { // Log the host Id; Output: "host id: [localhost]" pantheios::log_NOTICE(PSTR("host id: ["), pantheios::hostId, PSTR("]")); return EXIT_SUCCESS; } catch(std::bad_alloc&) { pantheios::log(pantheios::alert, PSTR("out of memory")); } catch(std::exception& x) { pantheios::log_CRITICAL(PSTR("Exception: "), x); } catch(...) { pantheios::logputs(pantheios::emergency, PSTR("Unexpected unknown error")); } return EXIT_FAILURE; } /* ////////////////////////////////////////////////////////////////////// */