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.

142 lines
4.8 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/scratch/test.scratch.be.N/test.scratch.be.N.cpp
  3. *
  4. * Purpose: Implementation file for the test.scratch.be.N project.
  5. *
  6. * Created: 18th October 2006
  7. * Updated: 20th December 2010
  8. *
  9. * Status: Wizard-generated
  10. *
  11. * License: (Licensed under the Synesis Software Open License)
  12. *
  13. * Copyright (c) 2006-2010, Synesis Software Pty Ltd.
  14. * All rights reserved.
  15. *
  16. * www: http://www.synesis.com.au/software
  17. *
  18. * ////////////////////////////////////////////////////////////////////// */
  19. #define PANTHEIOS_NO_INCLUDE_OS_AND_3PTYLIB_STRING_ACCESS
  20. /* Pantheios Header Files */
  21. #include <pantheios/pantheios.hpp>
  22. #include <pantheios/frontends/fe.N.h>
  23. #include <pantheios/backend.h>
  24. #include <pantheios/backends/be.N.h>
  25. #include <pantheios/backends/bec.file.h>
  26. #include <pantheios/backends/bec.fprintf.h>
  27. #if defined(PLATFORMSTL_OS_IS_UNIX)
  28. # include <pantheios/backends/bec.syslog.h>
  29. #elif defined(PLATFORMSTL_OS_IS_WINDOWS)
  30. # include <pantheios/backends/bec.WindowsDebugger.h>
  31. # include <pantheios/backends/bec.WindowsSyslog.h>
  32. #endif /* OS */
  33. /* STLSoft Header Files */
  34. #include <stlsoft/stlsoft.h>
  35. /* Standard C++ Header Files */
  36. #include <exception>
  37. /* Standard C Header Files */
  38. #include <stdio.h>
  39. #include <stdlib.h>
  40. /* /////////////////////////////////////////////////////////////////////////
  41. * Globals
  42. */
  43. PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.scratch.be.N");
  44. PANTHEIOS_EXTERN_C pan_fe_N_t PAN_FE_N_SEVERITY_CEILINGS[] =
  45. {
  46. { 1, PANTHEIOS_SEV_NOTICE } /* Filters out everything below 'notice' */
  47. , { 2, PANTHEIOS_SEV_INFORMATIONAL } /* Filters out everything below 'informational' */
  48. , { 3, PANTHEIOS_SEV_ERROR } /* Allows only 'error', 'critical', 'alert', 'emergency' */
  49. , { 4, PANTHEIOS_SEV_WARNING } /* Allows only 'warning', 'error', 'critical', 'alert', 'emergency' */
  50. , { 5, PANTHEIOS_SEV_DEBUG } /* Allows all stock severities */
  51. , { 0, PANTHEIOS_SEV_NOTICE } /* Terminates the array; sets the default ceiling to 'notice' */
  52. };
  53. PANTHEIOS_EXTERN_C pan_be_N_t PAN_BE_N_BACKEND_LIST[] =
  54. {
  55. PANTHEIOS_BE_N_STDFORM_ENTRY(1, pantheios_be_file, 0)
  56. , PANTHEIOS_BE_N_STDFORM_ENTRY(2, pantheios_be_fprintf, PANTHEIOS_BE_N_F_ID_MUST_MATCH_CUSTOM28)
  57. #if defined(PLATFORMSTL_OS_IS_UNIX)
  58. , PANTHEIOS_BE_N_STDFORM_ENTRY(4, pantheios_be_syslog, PANTHEIOS_BE_N_F_IGNORE_INIT_FAILURE)
  59. #elif defined(PLATFORMSTL_OS_IS_WINDOWS)
  60. , PANTHEIOS_BE_N_STDFORM_ENTRY(3, pantheios_be_WindowsDebugger, 0)
  61. , PANTHEIOS_BE_N_STDFORM_ENTRY(4, pantheios_be_WindowsSyslog, PANTHEIOS_BE_N_F_IGNORE_INIT_FAILURE)
  62. #endif /* OS */
  63. , PANTHEIOS_BE_N_STDFORM_ENTRY(5, pantheios_be_file, PANTHEIOS_BE_N_F_IGNORE_NONMATCHED_CUSTOM28_ID)
  64. , PANTHEIOS_BE_N_TERMINATOR_ENTRY
  65. };
  66. #if defined(PLATFORMSTL_OS_IS_WINDOWS)
  67. PANTHEIOS_CALL(void) pantheios_be_WindowsDebugger_getAppInit(
  68. int backEndId
  69. , pan_be_WindowsDebugger_init_t* init) /* throw() */
  70. {
  71. init->flags |= PANTHEIOS_BE_WINDOWSDEBUGGER_F_DETAILS_AT_START;
  72. }
  73. #endif /* PLATFORMSTL_OS_IS_WIN?? */
  74. /* ////////////////////////////////////////////////////////////////////// */
  75. static int main_(int /* argc */, char ** /*argv*/)
  76. {
  77. #ifdef PANTHEIOS_USES_VARIADIC_MACROS
  78. PANTHEIOS_TRACE_PRINTF(PANTHEIOS_SEV_ERROR, "Something went wrong here: %s %d", "abc", 10);
  79. #endif /* PANTHEIOS_USES_VARIADIC_MACROS */
  80. #ifdef PANTHEIOS_USES_VARIADIC_MACROS
  81. PANTHEIOS_TRACE_NOTICE("notice");
  82. #endif /* PANTHEIOS_USES_VARIADIC_MACROS */
  83. pantheios::log_DEBUG("debug");
  84. pantheios::log_INFORMATIONAL("info");
  85. pantheios_be_file_setFilePath("file.log", PANTHEIOS_BE_FILE_F_TRUNCATE, PANTHEIOS_BE_FILE_F_TRUNCATE, 1);
  86. pantheios::log_NOTICE("notice");
  87. pantheios::log_WARNING("warn");
  88. pantheios::log_ERROR("error");
  89. pantheios::log_CRITICAL("critical");
  90. pantheios_be_file_setFilePath("file-5.log", PANTHEIOS_BE_FILE_F_DISCARD_CACHED_CONTENTS, PANTHEIOS_BE_FILE_F_DISCARD_CACHED_CONTENTS, 5);
  91. pantheios::log_ALERT("alert");
  92. pantheios::log_EMERGENCY("emergency");
  93. pantheios::log(pantheios::warning(2), "this is targeted to go to the console (2)");
  94. pantheios::log(pantheios::error(4), "this is targeted to go to the syslog (4)");
  95. pantheios::log(pantheios::error(5), "this is targeted to go to the file (5)");
  96. return EXIT_SUCCESS;
  97. }
  98. int main(int argc, char *argv[])
  99. {
  100. try
  101. {
  102. return main_(argc, argv);
  103. }
  104. catch(std::exception &x)
  105. {
  106. fprintf(stderr, "Unhandled error: %s\n", x.what());
  107. }
  108. catch(...)
  109. {
  110. fprintf(stderr, "Unhandled unknown error\n");
  111. }
  112. return EXIT_FAILURE;
  113. }
  114. /* ///////////////////////////// end of file //////////////////////////// */