//
//  Copyright © 2001 - 2002, RESON Inc. All Rights Reserved.
//
//  No part of this file may be reproduced or transmitted in any form or by
//  any means, electronic or mechanical, including photocopy, recording, or
//  information storage or retrieval system, without permission in writing
//  from RESON Inc.
//
//  Filename:   SurveyEventLog.h
//
//  Project:    6046
//
//  Author(s):  P. Moberg - Initial creation.
//              W. Arcus  - Substantial changes and main implementation.
//
//  Purpose:    CLog class defintion file.
//
//  Notes:      
//

#if !defined(AFX_LOG_H__10B40E66_08F6_425E_A45D_F6FDA45F5D9D__INCLUDED_)
#define AFX_LOG_H__10B40E66_08F6_425E_A45D_F6FDA45F5D9D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CAlarm;                                           // Forward definition.

class CSurveyEventLog  
{
public:

    ///////////////
    // Services.

                            CSurveyEventLog         (   void );
    virtual                ~CSurveyEventLog         (   void );

    bool                    Start                   (   LPCTSTR                     lpszPath );
    bool                    Stop                    (   void );

    void                    SetAlarmCallback        (   const CAlarm               *pAlarm );

    static
    int _cdecl              ReportEvent             (   int                         iEventType,                 // Survey event (ESURVEYEVENT).
                                                        int                         iAction,                    // Action if an alarm or status change, otherwise iUnspecified_c.
                                                        int                         iId,                        // Id if an alarm or status change, otherwise iUnspecified_c.
                                                        char                       *pszMsg, ... );              // printf style message details of message or alarm.

private:

    ///////////////
    // Attributes.

    static
    CSurveyEventLog        *m_pthis;

    bool                    m_bAllowDiagnostics;
    HANDLE                  m_hLogFile;
    CAlarm                 *m_pAlarm;

    ///////////////
    // Services.

    bool                    WriteToLogFile          (   char                       *pszMessage );

    bool                    AreDiagnosticsEnabled   (   void );

    bool                    ReportAlarm             (   const int                  &riEventAction,
                                                        const int                  &riEventId,
                                                        const DWORD                &rdwTimestamp,
                                                        const LPCTSTR               lpszMessage );

                            CSurveyEventLog         (   const CSurveyEventLog       &rRhs );                    // Not implemented thus private to prevent use.
    CSurveyEventLog &       operator =              (   const CSurveyEventLog       &rRhs );                    // Not implemented thus private to prevent use.

};

#endif // !defined(AFX_LOG_H__10B40E66_08F6_425E_A45D_F6FDA45F5D9D__INCLUDED_)
