wdebug.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <stdlib.h>
  19. #include "wdebug.h"
  20. #include "streamer.h"
  21. #include "odevice.h"
  22. static MsgManager *msg_manager=NULL;
  23. static int debug_enabled=0;
  24. static ostream *debug_ostream=NULL;
  25. static Streamer debug_streamer;
  26. static int info_enabled=0;
  27. static ostream *info_ostream=NULL;
  28. static Streamer info_streamer;
  29. static int warn_enabled=0;
  30. static ostream *warn_ostream=NULL;
  31. static Streamer warn_streamer;
  32. static int error_enabled=0;
  33. static ostream *error_ostream=NULL;
  34. static Streamer error_streamer;
  35. int MsgManager::setAllStreams(OutputDevice *device)
  36. {
  37. if (device==NULL)
  38. return(1);
  39. debug_streamer.setOutputDevice(device);
  40. delete(debug_ostream);
  41. debug_ostream=new ostream(&debug_streamer);
  42. info_streamer.setOutputDevice(device);
  43. delete(info_ostream);
  44. info_ostream=new ostream(&info_streamer);
  45. warn_streamer.setOutputDevice(device);
  46. delete(warn_ostream);
  47. warn_ostream=new ostream(&warn_streamer);
  48. error_streamer.setOutputDevice(device);
  49. delete(error_ostream);
  50. error_ostream=new ostream(&error_streamer);
  51. return(0);
  52. }
  53. int MsgManager::setDebugStream(OutputDevice *device)
  54. {
  55. if (device==NULL)
  56. return(1);
  57. debug_streamer.setOutputDevice(device);
  58. delete(debug_ostream);
  59. debug_ostream=new ostream(&debug_streamer);
  60. return(0);
  61. }
  62. int MsgManager::setInfoStream(OutputDevice *device)
  63. {
  64. if (device==NULL)
  65. return(1);
  66. info_streamer.setOutputDevice(device);
  67. delete(info_ostream);
  68. info_ostream=new ostream(&info_streamer);
  69. return(0);
  70. }
  71. int MsgManager::setWarnStream(OutputDevice *device)
  72. {
  73. if (device==NULL)
  74. return(1);
  75. warn_streamer.setOutputDevice(device);
  76. delete(warn_ostream);
  77. warn_ostream=new ostream(&warn_streamer);
  78. return(0);
  79. }
  80. int MsgManager::setErrorStream(OutputDevice *device)
  81. {
  82. if (device==NULL)
  83. return(1);
  84. error_streamer.setOutputDevice(device);
  85. delete(error_ostream);
  86. error_ostream=new ostream(&error_streamer);
  87. return(0);
  88. }
  89. ostream *MsgManager::debugStream(void)
  90. {
  91. return(debug_ostream);
  92. }
  93. ostream *MsgManager::infoStream(void)
  94. {
  95. return(info_ostream);
  96. }
  97. ostream *MsgManager::warnStream(void)
  98. {
  99. return(warn_ostream);
  100. }
  101. ostream *MsgManager::errorStream(void)
  102. {
  103. return(error_ostream);
  104. }