// WMLogMgr.h: interface for the WMLogMgr class.
//
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2003 Robert Cunnings. All rights reserved.
//
// You may copy, modify, distribute or publish this code free of charge.
//
// NO WARRANTY: This software is provided AS IS, without warranty of any kind.
//
//////////////////////////////////////////////////////////////////////
//
// WMLogMgr class - a class for logging support.
// 
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_WMLOGMGR_H__EAEB4171_0491_11D3_9E11_00105AABC815__INCLUDED_)
#define AFX_WMLOGMGR_H__EAEB4171_0491_11D3_9E11_00105AABC815__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "WMLogRec.h"
#include <fstream>
using namespace std;

class WMLogMgr  
{
public:
	WMLogMgr();
	virtual ~WMLogMgr();

	// Logging
	void OpenServerLogFile();
	void OpenUserAgentLogFile();
	void OpenSOAPTraceLogFile();
	void WriteServerLog (COMLOGREC& LogRec);
	void WriteUserAgentLog (const string& strUserAgent);
	void WriteSOAPTraceLog(const string& strData);
	BOOL OpenLogFiles();
	void FlushLogFiles();

	void EnableServerLog(bool bFlag);
	void EnableUserAgentLog(bool bFlag);
	void EnableSOAPTraceLog(bool bFlag);

	// thread synchronization
	CRITICAL_SECTION m_CSServerLog;
	CRITICAL_SECTION m_CSUserAgentLog;
	CRITICAL_SECTION m_CSSOAPTraceLog;

	// log files
	ofstream        m_fileServerLog;
	ofstream        m_fileUserAgentLog;
	ofstream        m_fileSOAPTraceLog;
	// time zone
	string          m_strTimeZone;
	// flags
	bool            m_bServerLogEnable;
	bool            m_bUserAgentLogEnable;
	bool            m_bSOAPTraceLogEnable;
	// file paths
	string          m_strServerLogPath;
	string          m_strUserAgentLogPath;
	string          m_strSOAPTraceLogPath;
    // log rotation period (msec)
    unsigned int    m_uRotationPeriod;
    unsigned int    m_uRotationStartTime;
};

#endif // !defined(AFX_WMLOGMGR_H__EAEB4171_0491_11D3_9E11_00105AABC815__INCLUDED_)
