core/CLogger.h
author David Anderson <dvander@alliedmods.net>
Fri Mar 02 08:34:13 2007 +0000 (2007-03-02)
changeset 558 fc0eec032efb
parent 370 d3a484f98f6d
permissions -rw-r--r--
added state change function
     1 /**
     2  * ===============================================================
     3  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     4  * ===============================================================
     5  *
     6  * This file is not open source and may not be copied without explicit
     7  * written permission of AlliedModders LLC.  This file may not be redistributed 
     8  * in whole or significant part.
     9  * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    10  *
    11  * Version: $Id$
    12  */
    13 
    14 #ifndef _INCLUDE_SOURCEMOD_CLOGGER_H_
    15 #define _INCLUDE_SOURCEMOD_CLOGGER_H_
    16 
    17 #include <sh_string.h>
    18 #include "sm_globals.h"
    19 
    20 using namespace SourceHook;
    21 
    22 enum LogType
    23 {
    24 	LogType_Normal,
    25 	LogType_Error
    26 };
    27 
    28 enum LoggingMode
    29 {
    30 	LoggingMode_Daily,
    31 	LoggingMode_PerMap,
    32 	LoggingMode_HL2
    33 };
    34 
    35 class CLogger : public SMGlobalClass
    36 {
    37 public:
    38 	CLogger() : m_ErrMapStart(false), m_Active(false), m_DelayedStart(false), m_DailyPrintHdr(false) {}
    39 public: //SMGlobalClass
    40 	void OnSourceModStartup(bool late);
    41 	void OnSourceModAllShutdown();
    42 public:
    43 	void InitLogger(LoggingMode mode, bool startlogging);
    44 	void CloseLogger();
    45 	void EnableLogging();
    46 	void DisableLogging();
    47 	void LogMessage(const char *msg, ...);
    48 	void LogError(const char *msg, ...);
    49 	void MapChange(const char *mapname);
    50 	const char *GetLogFileName(LogType type) const;
    51 	LoggingMode GetLoggingMode() const;
    52 private:
    53 	void _CloseFile();
    54 	void _NewMapFile();
    55 	void _PrintToHL2Log(const char *fmt, va_list ap);
    56 private:
    57 	String m_NrmFileName;
    58 	String m_ErrFileName;
    59 	String m_CurMapName;
    60 	LoggingMode m_mode;
    61 	int m_CurDay;
    62 	bool m_ErrMapStart;
    63 	bool m_Active;
    64 	bool m_DelayedStart;
    65 	bool m_DailyPrintHdr;
    66 };
    67 
    68 extern CLogger g_Logger;
    69 
    70 #endif // _INCLUDE_SOURCEMOD_CLOGGER_H_