| 1 | /* |
|---|
| 2 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
|---|
| 3 | * |
|---|
| 4 | * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> |
|---|
| 5 | * |
|---|
| 6 | * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | * (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * This program is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | * GNU General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License |
|---|
| 17 | * along with this program; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | /** \file |
|---|
| 22 | \ingroup u2w |
|---|
| 23 | */ |
|---|
| 24 | |
|---|
| 25 | #include "WorldLog.h" |
|---|
| 26 | #include "Policies/SingletonImp.h" |
|---|
| 27 | #include "Config/ConfigEnv.h" |
|---|
| 28 | |
|---|
| 29 | #define CLASS_LOCK Trinity::ClassLevelLockable<WorldLog, ZThread::FastMutex> |
|---|
| 30 | INSTANTIATE_SINGLETON_2(WorldLog, CLASS_LOCK); |
|---|
| 31 | INSTANTIATE_CLASS_MUTEX(WorldLog, ZThread::FastMutex); |
|---|
| 32 | |
|---|
| 33 | #define WORLD_LOG_FILE_STRING "world.log" |
|---|
| 34 | |
|---|
| 35 | /// Open the log file (if specified so in the configuration file) |
|---|
| 36 | void WorldLog::Initialize() |
|---|
| 37 | { |
|---|
| 38 | std::string logsDir = sConfig.GetStringDefault("LogsDir",""); |
|---|
| 39 | |
|---|
| 40 | if(!logsDir.empty()) |
|---|
| 41 | { |
|---|
| 42 | if((logsDir.at(logsDir.length()-1)!='/') && (logsDir.at(logsDir.length()-1)!='\\')) |
|---|
| 43 | logsDir.append("/"); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | std::string logname = sConfig.GetStringDefault("WorldLogFile", ""); |
|---|
| 47 | if(!logname.empty()) |
|---|
| 48 | { |
|---|
| 49 | i_file = fopen((logsDir+logname).c_str(), "w"); |
|---|
| 50 | } |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | #define sWorldLog WorldLog::Instance() |
|---|