2007-01-25 23:36:38 +01:00
|
|
|
/**
|
2007-03-22 22:50:20 +01:00
|
|
|
* vim: set ts=4 :
|
2007-01-25 23:36:38 +01:00
|
|
|
* ===============================================================
|
|
|
|
* SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
|
|
|
|
* ===============================================================
|
|
|
|
*
|
|
|
|
* This file is not open source and may not be copied without explicit
|
|
|
|
* written permission of AlliedModders LLC. This file may not be redistributed
|
|
|
|
* in whole or significant part.
|
|
|
|
* For information, see LICENSE.txt or http://www.sourcemod.net/license.php
|
|
|
|
*
|
|
|
|
* Version: $Id$
|
|
|
|
*/
|
|
|
|
|
2007-01-05 00:41:51 +01:00
|
|
|
#ifndef _INCLUDE_SOURCEMOD_CLOGGER_H_
|
|
|
|
#define _INCLUDE_SOURCEMOD_CLOGGER_H_
|
|
|
|
|
|
|
|
#include <sh_string.h>
|
2007-01-16 21:36:09 +01:00
|
|
|
#include "sm_globals.h"
|
2007-01-05 00:41:51 +01:00
|
|
|
|
|
|
|
using namespace SourceHook;
|
|
|
|
|
|
|
|
enum LogType
|
|
|
|
{
|
|
|
|
LogType_Normal,
|
|
|
|
LogType_Error
|
|
|
|
};
|
|
|
|
|
|
|
|
enum LoggingMode
|
|
|
|
{
|
|
|
|
LoggingMode_Daily,
|
|
|
|
LoggingMode_PerMap,
|
2007-04-05 05:02:00 +02:00
|
|
|
LoggingMode_Game
|
2007-01-05 00:41:51 +01:00
|
|
|
};
|
|
|
|
|
2007-03-15 05:45:17 +01:00
|
|
|
class Logger : public SMGlobalClass
|
2007-01-05 00:41:51 +01:00
|
|
|
{
|
|
|
|
public:
|
2007-04-05 05:02:00 +02:00
|
|
|
Logger() : m_Mode(LoggingMode_Daily), m_ErrMapStart(false), m_Active(false), m_DelayedStart(false), m_DailyPrintHdr(false), m_InitialState(true), m_FirstPass(true) {}
|
2007-01-11 02:11:24 +01:00
|
|
|
public: //SMGlobalClass
|
2007-04-05 05:02:00 +02:00
|
|
|
CoreConfigErr OnSourceModConfigChanged(const char *option, const char *value);
|
2007-01-11 02:11:24 +01:00
|
|
|
void OnSourceModStartup(bool late);
|
|
|
|
void OnSourceModAllShutdown();
|
2007-01-05 00:41:51 +01:00
|
|
|
public:
|
|
|
|
void InitLogger(LoggingMode mode, bool startlogging);
|
|
|
|
void CloseLogger();
|
|
|
|
void EnableLogging();
|
|
|
|
void DisableLogging();
|
|
|
|
void LogMessage(const char *msg, ...);
|
2007-01-06 08:53:34 +01:00
|
|
|
void LogError(const char *msg, ...);
|
2007-01-05 00:41:51 +01:00
|
|
|
void MapChange(const char *mapname);
|
2007-01-11 00:49:22 +01:00
|
|
|
const char *GetLogFileName(LogType type) const;
|
|
|
|
LoggingMode GetLoggingMode() const;
|
2007-01-05 00:41:51 +01:00
|
|
|
private:
|
|
|
|
void _CloseFile();
|
|
|
|
void _NewMapFile();
|
2007-04-05 05:02:00 +02:00
|
|
|
void _PrintToGameLog(const char *fmt, va_list ap);
|
2007-01-05 00:41:51 +01:00
|
|
|
private:
|
|
|
|
String m_NrmFileName;
|
|
|
|
String m_ErrFileName;
|
|
|
|
String m_CurMapName;
|
2007-04-05 05:02:00 +02:00
|
|
|
LoggingMode m_Mode;
|
2007-01-05 00:41:51 +01:00
|
|
|
int m_CurDay;
|
|
|
|
bool m_ErrMapStart;
|
|
|
|
bool m_Active;
|
|
|
|
bool m_DelayedStart;
|
|
|
|
bool m_DailyPrintHdr;
|
2007-04-05 05:02:00 +02:00
|
|
|
bool m_InitialState;
|
|
|
|
bool m_FirstPass;
|
2007-01-05 00:41:51 +01:00
|
|
|
};
|
|
|
|
|
2007-03-15 05:45:17 +01:00
|
|
|
extern Logger g_Logger;
|
2007-01-05 00:41:51 +01:00
|
|
|
|
2007-01-16 21:36:09 +01:00
|
|
|
#endif // _INCLUDE_SOURCEMOD_CLOGGER_H_
|