You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.4 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: examples/c/example.c.extended_severity/example.c.extended_severity.c
  3. *
  4. * Purpose: C example program for Pantheios. Demonstrates:
  5. *
  6. * - how the Pantheios libraries must be explicitly
  7. * initialised in a C program; this is not the case in
  8. * C++ programs
  9. * - use of extended severity information, via
  10. * PANTHEIOS_MAKE_EXTENDED_SEVERITY()
  11. *
  12. * Created: 21st May 2009
  13. * Updated: 22nd March 2010
  14. *
  15. * www: http://www.pantheios.org/
  16. *
  17. * License: This source code is placed into the public domain 2006
  18. * by Synesis Software Pty Ltd. There are no restrictions
  19. * whatsoever to your use of the software.
  20. *
  21. * This software is provided "as is", and any warranties,
  22. * express or implied, of any kind and for any purpose, are
  23. * disclaimed.
  24. *
  25. * ////////////////////////////////////////////////////////////////////// */
  26. /* Pantheios Header Files */
  27. #include <pantheios/pantheios.h>
  28. /* Standard C Header Files */
  29. #include <stdlib.h>
  30. /* /////////////////////////////////////////////////////////////////////////
  31. * Compiler compatibility
  32. */
  33. #ifdef STLSOFT_COMPILER_IS_BORLAND
  34. # pragma warn -8008
  35. # pragma warn -8066
  36. #endif
  37. /* ////////////////////////////////////////////////////////////////////// */
  38. /* Define the stock front-end process identity, so that it links when using
  39. * fe.N, fe.simple, etc. */
  40. const PAN_CHAR_T PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("example.c.extended_severity");
  41. /* ////////////////////////////////////////////////////////////////////// */
  42. int main()
  43. {
  44. int i = pantheios_init();
  45. if(i >= 0)
  46. {
  47. /* 1. Using the Pantheios API macro PANTHEIOS_MAKE_EXTENDED_SEVERITY() */
  48. pantheios_logprintf(PANTHEIOS_MAKE_EXTENDED_SEVERITY(PANTHEIOS_SEV_NOTICE, 10), PANTHEIOS_LITERAL_STRING("hello"));
  49. /* 2 (a). In your code, you'd define your own, most succinct, symbol, e.g. ACME_XSEV(sev, xi28) */
  50. #define ACME_XSEV(sev, xi28) PANTHEIOS_MAKE_EXTENDED_SEVERITY(PANTHEIOS_SEV_ ## sev, xi28)
  51. /* 2 (b). and use it as follows */
  52. pantheios_logprintf(ACME_XSEV(NOTICE, 10), PANTHEIOS_LITERAL_STRING("hello"));
  53. pantheios_uninit();
  54. }
  55. return EXIT_SUCCESS;
  56. }
  57. /* ///////////////////////////// end of file //////////////////////////// */