wavelength 1.0.0
Loading...
Searching...
No Matches
debug.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5#include "os/binstream.h"
6#include "os/prnstream.h"
7
8#ifdef VIDEO_STANDARD_PAL
9#include "os/file.h"
10#endif
11
18class Debug : public PrnStream {
19public:
27
34 ~Debug() override;
35
44 void Print(const char *pszText) override;
45
46#ifdef VIDEO_STANDARD_PAL
57 void OpenLog(const char *pszFile, bool bAppend);
58#else
68 void OpenLog(const char *pszFile);
69#endif
70
79 void CloseLog();
80
90 typedef void (*ModalCallback)(int *pState, const char *pszMessage);
91
97 void SetModalCallback(ModalCallback pfnCallback) {
98 mModalCallback = pfnCallback;
99 }
100
103 return mModalCallback;
104 }
105
106private:
107 int mReserved08; // +0x08, cleared by the constructor and not yet identified.
108 int mReserved0C; // +0x0c, cleared by the constructor and not yet identified.
109 int mEnabled; // Non-zero while the stream writes.
110#ifdef VIDEO_STANDARD_PAL
111 std::unique_ptr<File> mLog; // The log file, or null for standard output.
112#else
113 std::unique_ptr<BinStream> mLog; // The log file, or null for standard output.
114#endif
115
118};
119
125extern Debug TheDebug;
126
136void DebugPrint(const char *pszFormat, ...);
137
148void DebugWarn(const char *pszFormat, ...);
149
160void DebugNotify(const char *pszFormat, ...);
161
172void DebugError(const char *pszFormat, ...);
Stream for diagnostic text, written to standard output or to a log file.
Definition debug.h:18
void(* ModalCallback)(int *pState, const char *pszMessage)
Routine that shows a message on the screen and waits for the player.
Definition debug.h:90
FileStream * mLog
Definition Debug.h:103
void Print(const char *pszText) override
Write diagnostic text, to the log file with each newline as a carriage return and a line feed,...
Debug()
Construct an enabled stream with no log file.
bool mEnabled
Definition Debug.h:102
ModalCallbackFunc mModalCallback
Definition Debug.h:104
void SetModalCallback(ModalCallback pfnCallback)
Set the routine that shows a message on the screen.
Definition debug.h:97
~Debug() override
Close the log file and release the stream.
ModalCallback GetModalCallback() const
Definition debug.h:102
void CloseLog()
Close the log file, if any.
void OpenLog(const char *pszFile)
Write the text to a log file from now on, replacing any log file.
PrnStream()
Construct a stream with a dump level of 0.
Definition prnstream.h:23
void DebugError(const char *pszFormat,...)
Format an error that the shipped build discards.
void DebugWarn(const char *pszFormat,...)
Format a warning that the shipped build discards.
void DebugNotify(const char *pszFormat,...)
Format a notice that the shipped build discards.
void DebugPrint(const char *pszFormat,...)
Format a diagnostic message that the shipped build discards.
Debug TheDebug
The diagnostic stream.