OLOG.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. // Filename : LOG.H
  21. // Description : Logging to locate hang
  22. #ifndef __LOG_H
  23. #define __LOG_H
  24. #include <OSTR.h>
  25. #include <OVQUEUE.h>
  26. //#define ENABLE_LOG
  27. #define DEBUG_LOG_GLOBAL 0
  28. #include <OLOG.h>
  29. // 1 to force enable debug log of that module, even though DEBUG_LOG_GLOBAL is 0
  30. // -1 to force disable debug log of that module, even though DEBUG_LOG_GLOBAL is 1
  31. // 0 to follow DEBUG_LOG_GLOBAL
  32. class Log
  33. {
  34. private:
  35. enum { LOG_VERSION = 12 };
  36. VLenQueue text_buffer[LOG_VERSION];
  37. String log_text;
  38. String log_file;
  39. int log_line;
  40. public:
  41. Log();
  42. ~Log();
  43. void mark_begin();
  44. void mark_end();
  45. void mark(char *msg, char *file, int line);
  46. void mark(int n, char *file, int line);
  47. void dump();
  48. static void debug_log( char *msg );
  49. static void debug_log( int n );
  50. };
  51. extern Log msg_log;
  52. #if defined(DEBUG) && defined(ENABLE_LOG)
  53. #define LOG_BEGIN msg_log.mark_begin()
  54. #define LOG_MSG(c) msg_log.mark(c, __FILE__, __LINE__)
  55. #define LOG_END msg_log.mark_end()
  56. #define LOG_DUMP msg_log.dump()
  57. #else
  58. #define LOG_BEGIN
  59. #define LOG_MSG(c)
  60. #define LOG_END
  61. #define LOG_DUMP
  62. #endif
  63. #ifndef DEBUG_LOG_LOCAL
  64. #define DEBUG_LOG_LOCAL 0
  65. #endif
  66. #if (DEBUG_LOG_GLOBAL + DEBUG_LOG_LOCAL > 0)
  67. #define DEBUG_LOG(c) Log::debug_log(c)
  68. #else
  69. #define DEBUG_LOG(c)
  70. #endif
  71. #endif