/*
Copyright 2004-2005 Electronic Arts Inc.
*/

// --- Include guard

#ifndef GAMETALKLOG_HPP
#define GAMETALKLOG_HPP

// --- Includes

#include "stdio.h"
#include <atlstr.h>
#include <string>
#include <fstream>
#include <iostream>
#include <time.h>

// --- Macros 

using namespace std;

namespace EA
{
namespace GameTalk
{
	// Log implementation
	class Log : public ofstream
	{
	public:
		static const int LOG_WRITE			= ios::out;
		static const int LOG_APPEND			= ios::app;

		static const int EXIT_MSG_SIZE		= 512;
		static const int MAX_EXIT_CODES		= 3;

		enum logLevels 
		{
			LEVEL_0,       // buffer all log messages
			LEVEL_1,       // buffer Level one, two and three log messages
			LEVEL_2,       // buffer Level two and three log messages
			LEVEL_3,       // buffer Level three log messages
			QUIET_MODE     // do not print out any messages
		};

		static Log* GetInstance();
		static void DestroyInstance();

	private:
		Log();
		virtual ~Log();

		void InitVars();
		void Init(const string &);
		void Init(const string &, int );
		void Init();

		char* GetExecTime();
		void GetExecTime(int *, int *);
		void OpenLog(const string &, int);
		void PrintHeader(int);

		string logName;
		enum logLevels logLevel;
		time_t startTime;

		static Log* mInstance;
	};

} // namespace GameTalk
} // namespace EA


#endif // GAMETALKLOG_HPP