2007-01-25 23:36:38 +01:00
|
|
|
/**
|
2007-03-22 22:50:20 +01:00
|
|
|
* vim: set ts=4 :
|
2007-08-01 04:12:47 +02:00
|
|
|
* ================================================================
|
|
|
|
* SourceMod
|
|
|
|
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
|
|
|
* ================================================================
|
2007-01-25 23:36:38 +01:00
|
|
|
*
|
2007-08-01 04:12:47 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License,
|
|
|
|
* version 3.0, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to
|
|
|
|
* link the code of this program (as well as its derivative works) to
|
|
|
|
* "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any
|
|
|
|
* Game MODs that run on software by the Valve Corporation. You must
|
|
|
|
* obey the GNU General Public License in all respects for all other
|
|
|
|
* code used. Additionally, AlliedModders LLC grants this exception
|
|
|
|
* to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version
|
|
|
|
* JULY-31-2007), or <http://www.sourcemod.net/license.php>.
|
2007-01-25 23:36:38 +01:00
|
|
|
*
|
|
|
|
* 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 07:25:11 +02:00
|
|
|
Logger() : m_Mode(LoggingMode_Daily), m_ErrMapStart(false),
|
|
|
|
m_Active(false), m_DelayedStart(false), m_DailyPrintHdr(false),
|
|
|
|
m_InitialState(true)
|
|
|
|
{
|
|
|
|
}
|
2007-01-11 02:11:24 +01:00
|
|
|
public: //SMGlobalClass
|
2007-04-05 07:25:11 +02:00
|
|
|
ConfigResult OnSourceModConfigChanged(const char *key,
|
|
|
|
const char *value,
|
|
|
|
ConfigSource source,
|
|
|
|
char *error,
|
|
|
|
size_t maxlength);
|
2007-01-11 02:11:24 +01:00
|
|
|
void OnSourceModStartup(bool late);
|
|
|
|
void OnSourceModAllShutdown();
|
2007-04-07 05:58:20 +02:00
|
|
|
void OnSourceModLevelChange(const char *mapName);
|
2007-01-05 00:41:51 +01:00
|
|
|
public:
|
2007-04-05 07:25:11 +02:00
|
|
|
void InitLogger(LoggingMode mode);
|
2007-01-05 00:41:51 +01:00
|
|
|
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-04-05 07:25:11 +02:00
|
|
|
void LogFatal(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;
|
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_
|