2 * Copyright (C) 2005,2006,2007 MaNGOS <http://www.mangosproject.org/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOSSERVER_LOG_H
20 #define MANGOSSERVER_LOG_H
23 #include "Policies/Singleton.h"
30 LOG_FILTER_TRANSPORT_MOVES
= 1,
31 LOG_FILTER_CREATURE_MOVES
= 2,
32 LOG_FILTER_VISIBILITY_CHANGES
= 4
54 const int Color_count
= int(WHITE
)+1;
56 class Log
: public MaNGOS::Singleton
<Log
, MaNGOS::ClassLevelLockable
<Log
, ZThread::FastMutex
> >
58 friend class MaNGOS::OperatorNew
<Log
>;
59 Log() : raLogfile(NULL
), logfile(NULL
), gmLogfile(NULL
), dberLogfile(NULL
), m_colored(false) { Initialize(); }
66 if( gmLogfile
!= NULL
)
70 if( dberLogfile
!= NULL
)
74 if (raLogfile
!= NULL
)
80 void InitColors(std::string init_str
);
81 void outTitle( const char * str
);
82 void outCommand( const char * str
, ...) ATTR_PRINTF(2,3);
83 void outString(); // any log level
85 void outString( const char * str
, ... ) ATTR_PRINTF(2,3);
87 void outError( const char * err
, ... ) ATTR_PRINTF(2,3);
89 void outBasic( const char * str
, ... ) ATTR_PRINTF(2,3);
91 void outDetail( const char * str
, ... ) ATTR_PRINTF(2,3);
93 void outDebugInLine( const char * str
, ... ) ATTR_PRINTF(2,3);
95 void outDebug( const char * str
, ... ) ATTR_PRINTF(2,3);
97 void outMenu( const char * str
, ... ) ATTR_PRINTF(2,3);
99 void outErrorDb( const char * str
, ... ) ATTR_PRINTF(2,3);
101 void outRALog( const char * str
, ... ) ATTR_PRINTF(2,3);
102 void SetLogLevel(char * Level
);
103 void SetLogFileLevel(char * Level
);
104 void SetColor(bool stdout_stream
, Color color
);
105 void ResetColor(bool stdout_stream
);
106 void outTimestamp(FILE* file
);
107 std::string
GetTimestampStr() const;
108 uint32
getLogFilter() const { return m_logFilter
; }
109 bool IsOutDebug() const { return m_logLevel
> 2 || m_logFileLevel
> 2 && logfile
; }
117 uint32 m_logFileLevel
;
123 #define sLog MaNGOS::Singleton<Log>::Instance()
126 #define DEBUG_LOG MaNGOS::Singleton<Log>::Instance().outDebug
131 // primary for script library
132 void MANGOS_DLL_SPEC
debug_log(const char * str
, ...) ATTR_PRINTF(1,2);
133 void MANGOS_DLL_SPEC
error_log(const char * str
, ...) ATTR_PRINTF(1,2);