diff --git a/stepmania/src/RageLog.cpp b/stepmania/src/RageLog.cpp index 6514967763..dfeb161a08 100644 --- a/stepmania/src/RageLog.cpp +++ b/stepmania/src/RageLog.cpp @@ -233,3 +233,19 @@ void RageLog::UnmapLog(const CString &key) { LogMaps.erase(key); } + +Checkpoint_::Checkpoint_(CString key_, int n, CString fmt, ...) +{ + key = ssprintf("%s:%i", key_.c_str(), n); + + va_list va; + va_start(va, fmt); + LOG->MapLog( key, vssprintf(fmt, va) ); + va_end(va); +} + +Checkpoint_::~Checkpoint_() +{ + LOG->UnmapLog( key ); +} + diff --git a/stepmania/src/RageLog.h b/stepmania/src/RageLog.h index dfed8f431c..06eae81e50 100644 --- a/stepmania/src/RageLog.h +++ b/stepmania/src/RageLog.h @@ -37,6 +37,15 @@ private: void UpdateMappedLog(); }; -extern RageLog* LOG; // global and accessable from anywhere in our program +/* Mapped log entry that's deleted on dtor. Note that this isn't extremely + * fast (like VDCHECKPOINT); don't use it in inner loops. */ +struct Checkpoint_ +{ + CString key; + Checkpoint_(CString key, int n, CString fmt, ...); + ~Checkpoint_(); +}; +#define Checkpoint(t) Checkpoint_ CP_( __FUNCTION__, __LINE__, t ) +extern RageLog* LOG; // global and accessable from anywhere in our program #endif