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.

132 lines
3.6 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/scratch/test.scratch.trace/test.scratch.trace.cpp
  3. *
  4. * Purpose: Implementation file for the trace_test project.
  5. *
  6. * Created: 5th August 2007
  7. * Updated: 6th August 2012
  8. *
  9. * Status: Wizard-generated
  10. *
  11. * License: (Licensed under the Synesis Software Open License)
  12. *
  13. * Copyright (c) 2007-2012, 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/trace.h>
  23. #include <pantheios/backend.h>
  24. #include <pantheios/backends/bec.WindowsConsole.h>
  25. #include <pantheios/backends/bec.WindowsDebugger.h>
  26. /* STLSoft Header Files */
  27. #include <stlsoft/stlsoft.h>
  28. /* Standard C++ Header Files */
  29. #include <exception>
  30. /* Standard C Header Files */
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #if defined(_MSC_VER) && \
  34. defined(_DEBUG)
  35. # include <crtdbg.h>
  36. #endif /* _MSC_VER) && _DEBUG */
  37. /* /////////////////////////////////////////////////////////////////////////
  38. * Globals
  39. */
  40. PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.scratch.trace");
  41. PANTHEIOS_CALL(void) pantheios_be_WindowsConsole_getAppInit(int /* backEndId */, pan_be_WindowsConsole_init_t *init) /* throw() */
  42. {
  43. init->flags |= PANTHEIOS_BE_INIT_F_NO_PROCESS_ID;
  44. init->flags |= PANTHEIOS_BE_INIT_F_NO_THREAD_ID;
  45. init->flags |= PANTHEIOS_BE_INIT_F_NO_DATETIME;
  46. init->flags |= PANTHEIOS_BE_INIT_F_NO_SEVERITY;
  47. init->flags |= PANTHEIOS_BE_INIT_F_DETAILS_AT_START;
  48. }
  49. PANTHEIOS_CALL(void) pantheios_be_WindowsDebugger_getAppInit(int /* backEndId */, pan_be_WindowsDebugger_init_t *init) /* throw() */
  50. {
  51. init->flags |= PANTHEIOS_BE_INIT_F_NO_PROCESS_ID;
  52. init->flags |= PANTHEIOS_BE_INIT_F_NO_THREAD_ID;
  53. init->flags |= PANTHEIOS_BE_INIT_F_NO_DATETIME;
  54. init->flags |= PANTHEIOS_BE_INIT_F_NO_SEVERITY;
  55. init->flags |= PANTHEIOS_BE_INIT_F_DETAILS_AT_START;
  56. }
  57. /* ////////////////////////////////////////////////////////////////////// */
  58. static int main_(int /* argc */, char** /*argv*/)
  59. {
  60. #ifndef __FUNCTION__
  61. # define __FUNCTION__ "main"
  62. #endif
  63. PANTHEIOS_TRACE_DEBUG("debug");
  64. PANTHEIOS_TRACE_INFORMATIONAL("informational");
  65. PANTHEIOS_TRACE_NOTICE("notice");
  66. PANTHEIOS_TRACE_WARNING("warning");
  67. PANTHEIOS_TRACE_ERROR("error");
  68. PANTHEIOS_TRACE_CRITICAL("critical");
  69. PANTHEIOS_TRACE_ALERT("alert");
  70. PANTHEIOS_TRACE_EMERGENCY("emergency");
  71. return EXIT_SUCCESS;
  72. }
  73. int main(int argc, char** argv)
  74. {
  75. int res;
  76. #if defined(_MSC_VER) && \
  77. defined(_DEBUG)
  78. _CrtMemState memState;
  79. #endif /* _MSC_VER && _MSC_VER */
  80. #if defined(_MSC_VER) && \
  81. defined(_DEBUG)
  82. _CrtMemCheckpoint(&memState);
  83. #endif /* _MSC_VER && _MSC_VER */
  84. #if 0
  85. { for(size_t i = 0; i < 0xffffffff; ++i){} }
  86. #endif /* 0 */
  87. try
  88. {
  89. res = main_(argc, argv);
  90. }
  91. catch(std::exception &x)
  92. {
  93. pantheios::log_ALERT("Unexpected general error: ", x, ". Application terminating");
  94. res = EXIT_FAILURE;
  95. }
  96. catch(...)
  97. {
  98. pantheios::logputs(pantheios::emergency, "Unhandled unknown error");
  99. res = EXIT_FAILURE;
  100. }
  101. #if defined(_MSC_VER) && \
  102. defined(_DEBUG)
  103. _CrtMemDumpAllObjectsSince(&memState);
  104. #endif /* _MSC_VER) && _DEBUG */
  105. return res;
  106. }
  107. /* ////////////////////////////////////////////////////////////////////// */