2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-01-04 20:19:14 -08:00
|
|
|
|
|
|
|
#ifndef UPDATELOGGING_H
|
|
|
|
#define UPDATELOGGING_H
|
|
|
|
|
|
|
|
#include "updatedefines.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
class UpdateLog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static UpdateLog & GetPrimaryLog()
|
|
|
|
{
|
2012-01-04 20:19:18 -08:00
|
|
|
static UpdateLog primaryLog;
|
|
|
|
return primaryLog;
|
2012-01-04 20:19:14 -08:00
|
|
|
}
|
|
|
|
|
2012-05-22 07:50:04 -07:00
|
|
|
void Init(NS_tchar* sourcePath, const NS_tchar* fileName,
|
|
|
|
const NS_tchar* alternateFileName, bool append);
|
2012-01-04 20:19:14 -08:00
|
|
|
void Finish();
|
2012-01-04 20:19:18 -08:00
|
|
|
void Flush();
|
2012-01-04 20:19:14 -08:00
|
|
|
void Printf(const char *fmt, ... );
|
|
|
|
|
|
|
|
~UpdateLog()
|
|
|
|
{
|
2012-01-04 20:19:18 -08:00
|
|
|
Finish();
|
2012-01-04 20:19:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
UpdateLog();
|
|
|
|
FILE *logFP;
|
|
|
|
NS_tchar* sourcePath;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define LOG(args) UpdateLog::GetPrimaryLog().Printf args
|
|
|
|
#define LogInit(PATHNAME_, FILENAME_) \
|
2012-05-22 07:50:04 -07:00
|
|
|
UpdateLog::GetPrimaryLog().Init(PATHNAME_, FILENAME_, 0, false)
|
|
|
|
#define LogInitAppend(PATHNAME_, FILENAME_, ALTERNATE_) \
|
|
|
|
UpdateLog::GetPrimaryLog().Init(PATHNAME_, FILENAME_, ALTERNATE_, true)
|
2012-01-04 20:19:14 -08:00
|
|
|
#define LogFinish() UpdateLog::GetPrimaryLog().Finish()
|
2012-01-04 20:19:18 -08:00
|
|
|
#define LogFlush() UpdateLog::GetPrimaryLog().Flush()
|
2012-01-04 20:19:14 -08:00
|
|
|
|
|
|
|
#endif
|