summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/server/config.h2
-rw-r--r--server/server/log.cpp10
-rw-r--r--server/server/log.h3
-rw-r--r--server/server/main.cpp17
4 files changed, 21 insertions, 11 deletions
diff --git a/server/server/config.h b/server/server/config.h
index d411411..5da2b80 100644
--- a/server/server/config.h
+++ b/server/server/config.h
@@ -99,7 +99,7 @@ public:
timeout = t;
}
};
- config(const char *path);
+ config(const char *path = NULL);
const int ban_time();
const int conn_count();
const int conn_time();
diff --git a/server/server/log.cpp b/server/server/log.cpp
index 9dfddf4..4f53866 100644
--- a/server/server/log.cpp
+++ b/server/server/log.cpp
@@ -51,10 +51,12 @@ logtofile::logtofile(const char *pth)
{
if(pth)
path = strdup(pth);
-}
-logtofile::logtofile()
-{
- path = strdup("./server.log");
+ else
+ {
+ std::string cfg_path = boost::filesystem::initial_path().string();
+ cfg_path += "/server.log";
+ path = strdup(cfg_path.c_str());
+ }
}
logtofile::~logtofile()
{
diff --git a/server/server/log.h b/server/server/log.h
index c55772a..f0898af 100644
--- a/server/server/log.h
+++ b/server/server/log.h
@@ -12,8 +12,7 @@ public:
logtofile& operator<<(size_t buf);
logtofile& operator<<(char buf);
~logtofile();
- logtofile(const char *pth);
- logtofile();
+ logtofile(const char *pth = NULL);
void lock()
{
log_mutex2.lock();
diff --git a/server/server/main.cpp b/server/server/main.cpp
index daa8a2d..1d36462 100644
--- a/server/server/main.cpp
+++ b/server/server/main.cpp
@@ -1137,10 +1137,19 @@ int main(int argc, char* argv[])
if (!cfg_path.empty())
cfg = new config(cfg_path.c_str());
else
- cfg = new config("./server.cfg");
-
- logger = new logtofile(cfg->log_path().c_str());
- dos_logger = new logtofile(cfg->dos_log_path().c_str());
+ cfg = new config;
+ if(!cfg->log_path().empty())
+ logger = new logtofile(cfg->log_path().c_str());
+ else
+ logger = new logtofile;
+ if(!cfg->dos_log_path().empty())
+ dos_logger = new logtofile(cfg->dos_log_path().c_str());
+ else
+ {
+ std::string cfg_path = boost::filesystem::initial_path().string();
+ cfg_path += "/server.log";
+ dos_logger = new logtofile(cfg_path.c_str());
+ }
while(true)
{
try