michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef UPDATELOGGING_H michael@0: #define UPDATELOGGING_H michael@0: michael@0: #include "updatedefines.h" michael@0: #include michael@0: michael@0: class UpdateLog michael@0: { michael@0: public: michael@0: static UpdateLog & GetPrimaryLog() michael@0: { michael@0: static UpdateLog primaryLog; michael@0: return primaryLog; michael@0: } michael@0: michael@0: void Init(NS_tchar* sourcePath, const NS_tchar* fileName, michael@0: const NS_tchar* alternateFileName, bool append); michael@0: void Finish(); michael@0: void Flush(); michael@0: void Printf(const char *fmt, ... ); michael@0: void WarnPrintf(const char *fmt, ... ); michael@0: michael@0: ~UpdateLog() michael@0: { michael@0: Finish(); michael@0: } michael@0: michael@0: protected: michael@0: UpdateLog(); michael@0: FILE *logFP; michael@0: NS_tchar* sourcePath; michael@0: }; michael@0: michael@0: #define LOG_WARN(args) UpdateLog::GetPrimaryLog().WarnPrintf args michael@0: #define LOG(args) UpdateLog::GetPrimaryLog().Printf args michael@0: #define LogInit(PATHNAME_, FILENAME_) \ michael@0: UpdateLog::GetPrimaryLog().Init(PATHNAME_, FILENAME_, 0, false) michael@0: #define LogInitAppend(PATHNAME_, FILENAME_, ALTERNATE_) \ michael@0: UpdateLog::GetPrimaryLog().Init(PATHNAME_, FILENAME_, ALTERNATE_, true) michael@0: #define LogFinish() UpdateLog::GetPrimaryLog().Finish() michael@0: #define LogFlush() UpdateLog::GetPrimaryLog().Flush() michael@0: michael@0: #endif