toolkit/mozapps/update/common/updatelogging.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/update/common/updatelogging.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef UPDATELOGGING_H
     1.9 +#define UPDATELOGGING_H
    1.10 +
    1.11 +#include "updatedefines.h"
    1.12 +#include <stdio.h>
    1.13 +
    1.14 +class UpdateLog
    1.15 +{
    1.16 +public:
    1.17 +  static UpdateLog & GetPrimaryLog() 
    1.18 +  {
    1.19 +    static UpdateLog primaryLog;
    1.20 +    return primaryLog;
    1.21 +  }
    1.22 +
    1.23 +  void Init(NS_tchar* sourcePath, const NS_tchar* fileName,
    1.24 +            const NS_tchar* alternateFileName, bool append);
    1.25 +  void Finish();
    1.26 +  void Flush();
    1.27 +  void Printf(const char *fmt, ... );
    1.28 +  void WarnPrintf(const char *fmt, ... );
    1.29 +
    1.30 +  ~UpdateLog()
    1.31 +  {
    1.32 +    Finish();
    1.33 +  }
    1.34 +
    1.35 +protected:
    1.36 +  UpdateLog();
    1.37 +  FILE *logFP;
    1.38 +  NS_tchar* sourcePath;
    1.39 +};
    1.40 +
    1.41 +#define LOG_WARN(args) UpdateLog::GetPrimaryLog().WarnPrintf args
    1.42 +#define LOG(args) UpdateLog::GetPrimaryLog().Printf args
    1.43 +#define LogInit(PATHNAME_, FILENAME_) \
    1.44 +  UpdateLog::GetPrimaryLog().Init(PATHNAME_, FILENAME_, 0, false)
    1.45 +#define LogInitAppend(PATHNAME_, FILENAME_, ALTERNATE_) \
    1.46 +  UpdateLog::GetPrimaryLog().Init(PATHNAME_, FILENAME_, ALTERNATE_, true)
    1.47 +#define LogFinish() UpdateLog::GetPrimaryLog().Finish()
    1.48 +#define LogFlush() UpdateLog::GetPrimaryLog().Flush()
    1.49 +
    1.50 +#endif

mercurial