From 2b8a68b83fcec52d24edcd8496fc2a390385edb0 Mon Sep 17 00:00:00 2001 From: Bob van Loosen Date: Sun, 17 Feb 2013 17:06:02 +0100 Subject: [PATCH] added: allow setting a subdirectory for the logfile from an argument --- src/bitvis/bitvis.cpp | 2 +- src/util/log.cpp | 10 +++++----- src/util/log.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bitvis/bitvis.cpp b/src/bitvis/bitvis.cpp index 95eb8c1..6238604 100644 --- a/src/bitvis/bitvis.cpp +++ b/src/bitvis/bitvis.cpp @@ -86,7 +86,7 @@ CBitVis::~CBitVis() void CBitVis::Setup() { //init the logfile - SetLogFile("bitvis.log"); + SetLogFile(".bitvis", "bitvis.log"); SetupSignals(); diff --git a/src/util/log.cpp b/src/util/log.cpp index 2e0ab0f..53c26eb 100644 --- a/src/util/log.cpp +++ b/src/util/log.cpp @@ -66,7 +66,7 @@ string GetStrTime() return buff; } -bool InitLog(string filename, ofstream& logfile) +bool InitLog(string directory, string filename, ofstream& logfile) { string homepath; if (!GetHomePath(homepath)) @@ -75,8 +75,8 @@ bool InitLog(string filename, ofstream& logfile) return false; } - string directory = homepath + ".bitvis/"; - string fullpath = directory + filename; + directory = homepath + directory; + string fullpath = directory + "/" + filename; //try to make the directory the log goes in if (mkdir(directory.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == -1) @@ -124,7 +124,7 @@ string PruneFunction(string function) return function.substr(spacepos + 1, parenpos - spacepos - 1); } -void SetLogFile(std::string filename) +void SetLogFile(const char* directory, const char* filename) { if (!g_logmutex) g_logmutex = new CMutex; @@ -139,7 +139,7 @@ void SetLogFile(std::string filename) g_logbuff = NULL; g_logbuffsize = 0; - if (!InitLog(filename, *g_logfile)) + if (!InitLog(directory, filename, *g_logfile)) g_printlogtofile = false; } diff --git a/src/util/log.h b/src/util/log.h index 67d6b01..1943f19 100644 --- a/src/util/log.h +++ b/src/util/log.h @@ -34,7 +34,7 @@ enum LogLevel #define LogDebug(fmt, ...) g_printdebuglevel ? PrintLog(fmt, __PRETTY_FUNCTION__, LogLevelDebug, ##__VA_ARGS__) : (void)0 void PrintLog (const char* fmt, const char* function, LogLevel loglevel, ...) __attribute__ ((format (printf, 1, 4))); -void SetLogFile(std::string logfile); +void SetLogFile(const char* directory, const char* filename); extern bool g_logtostderr; extern bool g_printlogtofile;